Bug #51313 [NEW]: str_replace doesn't work properly with non-ascii characters.
| From: | ez dot amiryo at gmail dot com | 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