From:             
Operating system: Mac OS X 10.6.7 / Windows 2003
PHP version:      5.3.6
Package:          mbstring related
Bug Type:         Bug
Bug description:mb_substr() fails on "UTF-32LE"

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

-- 
Edit bug report at http://bugs.php.net/bug.php?id=54494&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=54494&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=54494&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=54494&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=54494&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=54494&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=54494&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=54494&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=54494&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=54494&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=54494&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=54494&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=54494&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=54494&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=54494&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=54494&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=54494&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=54494&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=54494&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=54494&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=54494&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=54494&r=mysqlcfg

Reply via email to