From: Operating system: OS X 10.6.4 PHP version: Irrelevant Package: Strings related Bug Type: Bug Bug description:substr() and $string[n] corrupt multi-byte UTF-8 strings
Description: ------------ (PHP 5.3.2 (cli) (built: Aug 7 2010 00:04:41) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies) When trying to extract a single character from a UTF-8-encoded Japanese string, instead of the expected character, one gets the dreaded black-diamond-question-mark-of-death. Test script: --------------- $s_string = "é岡ã¯è¸ãæãã§ãã"; echo $s_string[3], "<p />"; // expected output is è¸ // actual output is � print_r($s_string[3]); // expected output is è¸ // actual output is � echo "<p />"; $sub = substr($s_string, 3, 1); echo $sub, "<p />"; // expected output is è¸ // actual output is � Expected result: ---------------- Expected output is è¸ Actual result: -------------- Actual output is � -- Edit bug report at http://bugs.php.net/bug.php?id=52810&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52810&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52810&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52810&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52810&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52810&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52810&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52810&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52810&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52810&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52810&r=support Expected behavior: http://bugs.php.net/fix.php?id=52810&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52810&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52810&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52810&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52810&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52810&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52810&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52810&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52810&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52810&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52810&r=mysqlcfg
