note 109937 added to ref.mbstring

From: Date: Tue, 04 Sep 2012 10:32:59 +0000
Subject: note 109937 added to ref.mbstring
Groups: php.notes 
Request: Send a blank email to php-notes+get-190475@lists.php.net to get a copy of this message
Please note that all the discussion about mb_str_replace in the comments is pretty pointless. str_replace works just fine with multibyte strings: <?php $string = '漢字はユニコード'; $needle = 'は'; $replace = 'Foo'; echo str_replace($needle, $replace, $string); // outputs: 漢字Fooユニコード ?> The usual problem is that the string is evaluated as binary string, meaning PHP is not aware of encodings at all. Problems arise if you are getting a value "from outside" somewhere (database, POST request) and the encoding of the needle and the haystack is not the same. That typically means the source code is not saved in the same encoding as you are receiving "from outside". Therefore the binary representations don't match and nothing happens. ---- Server IP: 69.147.83.197 Probable Submitter: 80.187.201.121 ---- Manual Page -- http://www.php.net/manual/en/ref.mbstring.php Edit -- https://master.php.net/note/edit/109937 Del: integrated -- https://master.php.net/note/delete/109937/integrated Del: useless -- https://master.php.net/note/delete/109937/useless Del: bad code -- https://master.php.net/note/delete/109937/bad+code Del: spam -- https://master.php.net/note/delete/109937/spam Del: non-english -- https://master.php.net/note/delete/109937/non-english Del: in docs -- https://master.php.net/note/delete/109937/in+docs Del: other reasons-- https://master.php.net/note/delete/109937 Reject -- https://master.php.net/note/reject/109937 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#190475) next »