|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-10-30 08:45 UTC] tony2001@php.net
[2006-11-07 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
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年预愎ぷ鞫?被嵋