Bug #51313 [NEW]: str_replace doesn't work properly with non-ascii characters.

From: Date: Wed, 17 Mar 2010 08:46:14 +0000
Subject: Bug #51313 [NEW]: str_replace doesn't work properly with non-ascii characters.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-148709@lists.php.net to get a copy of this message
From: Operating system: Linux PHP version: 5.2.13 Package: I18N and L10N related Bug Type: Bug Bug description:str_replace doesn't work properly with non-ascii characters. Description: ------------ str_replace doesn't work properly with non-ascii(128~) characters in arrays. I tested below script on cp949 machine. Test script: --------------- <?php echo ConvertPokerCardString( 'QS 4C JC 9D JH 7H AC' ); function ConvertPokerCardString( $str ) { return( str_replace( array('D','S','H','C'), array('◆','♠','♥'.'♣'), $str ) ); // below codes works well. /* $str = str_replace( 'D', '◆', $str ); $str = str_replace( 'H', '♥', $str ); $str = str_replace( 'S', '♠', $str ); $str = str_replace( 'C', '♣', $str ); return $str; */ } ?> Expected result: ---------------- Q♠ 4♣ J♣ 9◆ J♥ 7♥ A♣ Actual result: -------------- Q♠ 4 J 9◆ J♥♣ 7♥♣ A -- Edit bug report at http://bugs.php.net/bug.php?id=51313&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51313&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51313&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51313&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51313&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51313&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51313&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51313&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51313&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51313&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51313&r=support Expected behavior: http://bugs.php.net/fix.php?id=51313&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51313&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51313&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51313&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51313&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51313&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51313&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51313&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51313&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51313&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51313&r=mysqlcfg

« previous php.bugs (#148709) next »