imap_utf8()中转换GBK编码的问题

服务器环境:ubunt feisty,php5.1.2,php5-imap 5.1.2-1ubuntu1

imap_utf8()不能转换GBK编码的汉字,GB2312没有问题
但可以使用iconv_mime_decode($string,0,”UTF-8″)来进行代替

参考: https://bugs.launchpad.net/ubuntu/+source/php5/+bug/137475

BUG重现:
nano test.php

<?php
echo imap_utf8("=?GBK?B?wbzP/A==?=");
echo "\n";
echo iconv_mime_decode("=?GBK?B?wbzP/A==?=",0,"UTF-8");
?>

执行:
php5 test.php

This entry was posted in Linux and tagged , , , , , . Bookmark the permalink.

One Response to imap_utf8()中转换GBK编码的问题

  1. Murphy Kuo says:

    Thanks for this tip and comparison
    I used this tip to fix a bug in receiving mails encoded with GBK but charset=gb2312 in the mail header. The mail receiver will use GB2312 to parse the mail but get garbled in some chinese words which are encoded by GBK which covers Traditional Chinese

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please copy the string QYjcJn to the field below:

以新浪微博帐号登录