ID:               39303
 Updated by:       [EMAIL PROTECTED]
 Reported By:      xueron at xueron dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         mbstring related
 Operating System: Redhat Linux AS 4.3
 PHP Version:      5.1.6
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip




Previous Comments:
------------------------------------------------------------------------

[2006-10-30 07:57:18] xueron at xueron dot com

Description:
------------
When i use mb_decode_mimeheader() to decode a long MIME-encoded Chinese
subject and convert it to UTF-8, there was something wrong if the
subject was splited into more than one parts, like this:

Subject:
=?gb2312?q?=D6=D8=D2=AA=BB=E1=D2=E9=CD=A8=D6=AA-06=C4=EA=B5=DA=C8=FD=BC?=

=?gb2312?q?=BE=B6=C8=BE=AD=BC=C3=B7=D6=CE=F6=BB=E1=F4=DF07=C4=EA=D4=A4=CB?=
 =?gb2312?q?=E3=B9=A4=D7=F7=B6=AF=D4=B1=BB=E1=D2=E9?=

It seems that mb_decode_mimeheader() decode and convert each part and
at last, concatenate them. But in fact, all parts should be decoded and
concatenated and then, do the charset convert.

Reproduce code:
---------------
    $s = mb_decode_mimeheader($s);
vs.
    $a = imap_mime_header_decode($s);
    if (is_array($a) && count($a) > 0) {
        $r = ''; $c = array();
        for ($i = 0; $i < count($a); $i++) {
            if ($a[$i]->charset == 'default') {
                array_push($c, 'ASCII');
            } else {
                array_push($c, $a[$i]->charset);
            }
            //$e = mb_detect_encoding($a[$i]->text, $c);
            //$o = mb_convert_encoding($a[$i]->text, "UTF-8", $c);
            //$r .= $o;
            $r .= $a[$i]->text;
        }
        $e = mb_detect_encoding($r, $c);
        $r = mb_convert_encoding($r, "UTF-8", $e);
    

Expected result:
----------------
&#37325;&#35201;&#20250;&#35758;&#36890;&#30693;-06&#24180;&#31532;&#19977;&#23395;&#24230;&#32463;&#27982;&#20998;&#26512;&#20250;&#26280;07&#24180;&#39044;&#31639;&#24037;&#20316;&#21160;&#21592;&#20250;&#35758;

Actual result:
--------------
&#37325;&#35201;&#20250;&#35758;&#36890;&#30693;-06&#24180;&#31532;&#19977;&#24452;&#26579;?&#26757;&#27835;&#40844;&#29394;?7&#24180;&#39044;&#24846;&#12407;&#38827;?&#34987;&#23883;


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=39303&edit=1

Reply via email to