|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51313 str_replace doesn't work properly with non-ascii characters.
Submitted: 2010-03-17 09:46 UTC Modified: 2010-03-17 09:52 UTC
From: ez dot amiryo at gmail dot com Assigned:
Status: Not a bug Package: I18N and L10N related
PHP Version: 5.2.13 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ez dot amiryo at gmail dot com
New email:
PHP Version: OS:


 [2010-03-17 09:46 UTC] ez dot amiryo at gmail dot com
str_replace doesn't work properly with non-ascii(128~) characters in arrays.
I tested below script on cp949 machine.

Test script:
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-17 09:47 UTC] ez dot amiryo at gmail dot com
sorry. this was my fault.
 [2010-03-17 09:52 UTC]
-Status: Closed +Status: Bogus
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Aug 03 21:01:24 2020 UTC