php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54494 mb_substr() fails on "UTF-32LE"
Submitted: 2011-04-08 17:05 UTC Modified: 2011-04-09 18:59 UTC
From: rodney dot rehm at medialize dot de Assigned: cataphract (profile)
Status: Closed Package: mbstring related
PHP Version: 5.3.6 OS: Mac OS X 10.6.7 / Windows 2003
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rodney dot rehm at medialize dot de
New email:
PHP Version: OS:

 

 [2011-04-08 17:05 UTC] rodney dot rehm at medialize dot de
Description:
------------
Iterating the characters of a UTF-32LE encoded string by using mb_substr() fails. Same string UTF-32BE encoded works as expected. 

Test script:
---------------
<?php

declare(encoding = 'UTF-8');
mb_internal_encoding('UTF-8');

header('Content-Type: text/plain; charset=UTF-32LE');

$string = "hällö wörld\n";
$string = mb_convert_encoding($string, "UTF-32LE");
$length = mb_strlen($string, "UTF-32LE");
echo mb_convert_encoding("Length: ". $length ."\n", "UTF-32LE");

echo $string;

for ($i=0; $i < $length; $i++) {
  echo mb_substr($string, $i, 1, "UTF-32LE");
}

?>

Expected result:
----------------
Length: 12
hällö wörld
hällö wörld

Actual result:
--------------
Length: 12
hällö wörld
häl

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-09 18:59 UTC] cataphract@php.net
Automatic comment from SVN on behalf of cataphract
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=310108
Log: - Fixed bug #54494: mb_substr() mishandles UTF-32LE and UCS-2LE.
 [2011-04-09 18:59 UTC] cataphract@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cataphract
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 15 09:01:26 2024 UTC