#49528 [Opn->Asn]: UTF-16 strings prefixed by BOMs wrondly converted
| From: | jani@php.net | Date: | Fri, 11 Sep 2009 08:21:17 +0000 |
| Subject: | #49528 [Opn->Asn]: UTF-16 strings prefixed by BOMs wrondly converted | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-142245@lists.php.net to get a copy of this message | ||
ID: 49528
Updated by: jani@php.net
Reported By: moriyoshi@php.net
-Status: Open
+Status: Assigned
Bug Type: mbstring related
-Operating System: N/A
+Operating System: *
PHP Version: 5.3SVN-2009-09-11 (SVN)
-Assigned To:
+Assigned To: moriyoshi
New Comment:
Moriyoshi propably added this report as reminder for himself.
Previous Comments:
------------------------------------------------------------------------
[2009-09-11 08:18:38] sjoerd@php.net
It can be argued that the BOM character U+FEFF should never be
converted, as it is no real character.
I don't think it is the task of mb_convert_encoding to detect the byte
order and interpret the BOM.
------------------------------------------------------------------------
[2009-09-11 07:45:05] moriyoshi@php.net
Description:
------------
The first character of a UTF-16 string prefixed by "\xff\xfe" (LE BOM)
gets converted to wrong Unicode codepoint. Moreover, the resulting
string contains the BOM itself while it is uncalled for.
Reproduce code:
---------------
<?php
var_dump(bin2hex(mb_convert_encoding("\xff\xfe\x01\x02\x03\x04",
"UCS-2", "UTF-16")));
?>
Expected result:
----------------
string(8) "02010403"
Actual result:
--------------
string(12) "feffff010403"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49528&edit=1