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