从 IMAP 电子邮件正文中读取日语字符
我尝试使用以下代码获取日语电子邮件正文:
header('Content-Type: text/html;charset=utf-8');
$mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}", "***@*****.com", "*******");
$email="[email protected]";
$num_mensaje = imap_search($mbox,"FROM $email");
$body = imap_fetchbody($mbox,$num_mensaje[0],"1");
echo imap_8bit($body));
但对我不起作用我看到这个 *$B$3$s$K$A$O!"$=$N$h$& ;$J
任何想法
提前致谢
i try to fetch the body of the email in japanese with this code:
header('Content-Type: text/html;charset=utf-8');
$mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}", "***@*****.com", "*******");
$email="[email protected]";
$num_mensaje = imap_search($mbox,"FROM $email");
$body = imap_fetchbody($mbox,$num_mensaje[0],"1");
echo imap_8bit($body));
but doesn't work for me i see this *$B$3$s$K$A$O!"$=$N$h$&$J
any ideas
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于
$B
是 JIS 编码中的主要控制序列之一,并且您的输出以*$B
开头,因此您的数据似乎来自那个来源。尝试使用 JIS(或 SJIS)中的 mb_convert_encoding 。编辑:如果您可能接受多种编码的日语,您可以查看 mb_detect_encoding 函数;使用适当的编码列表。
Since
<ESC>$B
is one of the primary control sequences in the JIS encodings, and your output begins*$B
, it would appear that your data has come from that source. Try using mb_convert_encoding from JIS (or SJIS).Edit: If you are potentially accepting Japanese from multiple encodings, you could look at the mb_detect_encoding function; making use of an appropriate encoding list.
我只尝试使用此代码片段将 ISO-2022-JP 消息解码为 UTF-8,它对我有用。
I've only tried to use this code snippet to decode ISO-2022-JP messages to UTF-8 and it worked for me.