php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49528 UTF-16 strings prefixed by BOMs wrondly converted
Submitted: 2009-09-11 07:45 UTC Modified: 2009-09-23 14:27 UTC
From: moriyoshi@php.net Assigned: moriyoshi (profile)
Status: Closed Package: mbstring related
PHP Version: 5.3SVN-2009-09-11 (SVN) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: moriyoshi@php.net
New email:
PHP Version: OS:

 

 [2009-09-11 07:45 UTC] 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"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-11 08:18 UTC] 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 08:21 UTC] jani@php.net
Moriyoshi propably added this report as reminder for himself.
 [2009-09-11 08:22 UTC] svn@php.net
Automatic comment from SVN on behalf of moriyoshi
Revision: http://svn.php.net/viewvc/?view=revision&revision=288260
Log: - Fix bug #49528 (UTF-16 strings prefixed by BOM wrongly converted).
 [2009-09-11 14:34 UTC] jani@php.net
Fixed -> closed (?) (or did you leave this open just for fun?)
 [2009-09-11 21:07 UTC] moriyoshi@php.net
I left this open because patch is not merged to 5.2 yet.

 [2009-09-23 14:27 UTC] moriyoshi@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 20:01:28 2024 UTC