Bug #51313 [Csd->Bgs]: str_replace doesn't work properly with non-ascii characters.
| From: | aharvey@php.net | 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