如何从imap_fetchbody解析日语字符(utf8?)



我正在拉下一封电子邮件,其中电子邮件中有英语,中文和日语。我正在使用 PHP/EZComponents 来做到这一点,但某个日语字符就是没有通过,所以我切换到 php imap_* 函数,看看它们是否可以工作。

这是我在下面看到的,以及我得到的输出。我需要以某种方式解码这个...我知道这已经很好地(阅读:过度/混乱地)记录在网络上,但我现在没有时间获得博士学位。任何帮助将不胜感激。

$hn='{imap.gmail.com:993/imap/ssl}INBOX';
$inbox = imap_open($hn,$username,$password,CL_EXPUNGE);
foreach($emails as $email_number) {
        $ov = imap_fetch_overview($inbox,$email_number,0);
        $msg = imap_fetchbody($inbox,$email_number,2);
       var_dump($msg);
  // doesnt work... .. but right idea?
  // var_dump( utf8_decode($msg) ); 
}

部分输出:

<font face=3D"Arial"><span lang=3D"EN-US" style=3D"font-size:10.5pt"><br></=
span></font><font color=3D"navy" face=3D"MS Gothic"><span lang=3D"JA" style=
=3D"font-size:10.5pt">=CC=EC=9A=DD=A4=AC=A4=A4=A4=A4=A4=AB=A4=E9=A1=A2</spa=
n></font></p><p style=3D"margin-right:0pt;margin-bottom:12pt;margin-left:0p=
t">


<font color=3D"navy" face=3D"MS Gothic"><span lang=3D"JA" style=3D"font-siz=
e:10.5pt"><br></span></font></p><p style=3D"margin-right:0pt;margin-bottom:=
12pt;margin-left:0pt"><font color=3D"navy" face=3D"MS Gothic"><span lang=3D=
"JA" style=3D"font-size:10.5pt">xxend</span></font></p>

我也遇到了这个问题,使用imap_fetchbody函数来获取邮件正文。

我发现从imap_fetchbody获取的字符串自动转换为带引号的可打印字符串。

我通过使用imap_qprint函数将获取的字符串主体转换为正确的字符串主体来解决此问题。

最新更新