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: ---------------- 重要会议通知-06年第三季度经济分析会暨07年预算工作动员会议 Actual result: -------------- 重要会议通知-06年第三径染?梅治龌狒?7年预愎ぷ鞫?被嵋 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39303&edit=1