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

From: Date: Wed, 17 Mar 2010 08:52:13 +0000
Subject: Bug #51313 [Csd->Bgs]: str_replace doesn't work properly with non-ascii characters.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-148712@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=51313&edit=1 ID: 51313 Updated by: aharvey@php.net Reported by: ez dot amiryo at gmail dot com Summary: str_replace doesn't work properly with non-ascii characters. -Status: Closed +Status: Bogus Type: Bug Package: I18N and L10N related Operating System: Linux PHP Version: 5.2.13 Previous Comments: ------------------------------------------------------------------------ [2010-03-17 09:47:26] ez dot amiryo at gmail dot com sorry. this was my fault. ------------------------------------------------------------------------ [2010-03-17 09:46:13] ez dot amiryo at gmail dot com 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 this bug report at http://bugs.php.net/bug.php?id=51313&edit=1

« previous php.bugs (#148712) next »