Edit report at http://bugs.php.net/bug.php?id=50954&edit=1
ID: 50954 Updated by: ahar...@php.net Reported by: hiroaki dot kawai at gmail dot com Summary: iconv_mime_encode fails in Q-encoding -Status: Bogus +Status: Duplicate Type: Bug Package: ICONV related PHP Version: 5.2.12 New Comment: It does indeed look like a dupe. Changing the status accordingly. Previous Comments: ------------------------------------------------------------------------ [2010-05-04 13:12:59] softex at kaliningrad dot ru This function does not work in Base64 mode too using utf-8 charset. ------------------------------------------------------------------------ [2010-04-29 20:58:39] softex at kaliningrad dot ru I have the same problem using non-ascii characters in second argument of the function. When to expect this patch to be included in new release? ------------------------------------------------------------------------ [2010-02-08 00:22:34] hiroaki dot kawai at gmail dot com I'm not sure this is a dup of #48289 because I could not reproduce the test case. So I created a separete report. If you are sure this is a dup of #48289, please mark this as "Duplicate" not "Bogus". Bogus means "the report was not a bug at last". ------------------------------------------------------------------------ [2010-02-07 17:37:26] j...@php.net Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. See bug #48289 ------------------------------------------------------------------------ [2010-02-07 14:15:50] hiroaki dot kawai at gmail dot com Description: ------------ iconv_mime_encode fails Q-encoding when encoding non-ascii chars, which case is very common. This problem does not happen if line-length is long enough to hold the encoded string in a single line. The code use unsigned int to capture expected byte. In Q-encoding, the value is goes to negative value (at iconv.c line 1295), and fails separating the value into multiple lines. Patch as following: =============================== --- iconv.c.orig 2008-12-31 20:17:49.000000000 +0900 +++ iconv.c 2010-02-07 11:01:54.436000000 +0900 @@ -1217,7 +1217,7 @@ prev_in_left = ini_in_left = in_left; ini_in_p = in_p; - for (out_size = char_cnt; out_size > 0;) { + for (out_size = (char_cnt-2)/3; out_size > 0;) { size_t prev_out_left; nbytes_required = 0; Reproduce code: --------------- <?php ini_set('error_reporting',E_ALL); echo iconv_mime_encode('a',"\xE3\x83\x86\xE3\x82\xB9\xE3\x83\x88\xE3\x83\x86\xE3\x82\xB9\xE3\x83\x88",array('output-charset'=>'UTF-8','input-charset'=>'UTF-8','scheme'=>'Q','line-length'=>30)); Expected result: ---------------- a: =?UTF-8?Q?=E3=83=86?= =?UTF-8?Q?=E3=82=B9?= =?UTF-8?Q?=E3=83=88?= =?UTF-8?Q?=E3=83=86?= =?UTF-8?Q?=E3=82=B9?= =?UTF-8?Q?=E3=83=88?= Actual result: -------------- Notice: iconv_mime_encode(): Unknown error (7) in /home/hawk/hoge.php on line 3 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=50954&edit=1