tags:

views:

156

answers:

2

why php's str_replace and many other string functions mess up the strings with special chars such ('é' 'à' ..) ? and how to fix this problem ?

+3  A: 

str_replace is not multi-byte (unicode) aware. use the according mb_* functions instead

in your place mb_ereg_replace sounds like the right option. you could as well just use the PCRE regex functions and specifying the X flag

knittl
A: 

PHP wasn't developed from the ground up to natively support UTF8. It may be useful to instead of specify the character literal, specify the entity reference / hex code of that in your replacement, eg \x3094 and replace that, I think it's more consistently supported.

Though it would help seeing your direct issue at hand, with more code.

meder