why isn\'t this working as expected:
echo str_replace(\"é\",\"é\",\"Fédération Camerounaise de Football\");
result:
\"F
//edit after comment
Fédération Camerounaise de Football
is an UTF-8
encoded string so i don't know what input is not utf-8
encoded in your document but you have two options.
your input that are passed to str_replace
is utf-8
but the characters that you have used in the functions to replace are ANSII
or something else => not work - this means your document is not utf-8
- this is why uft8_decode
works
str_replace(ANSII, ANSII, CONVERT_TO_ANSII(UTF-8))
your input is not utf-8
and your document is - so this would work
str_replace(UTF-8, UTF-8, CONVERT_TO_UTF-8(ANSII))
str_replace
works great with multibyte characters - your problem is not the function its is because you try to replace different encoding types. instead of using a alternative function - i suggest you to fix the input that are passed to str_replace
to utf-8
and make sure that your document is utf-8
encoded too.
if your source only support non utf-8
encoding use utf8_encode
to convert your input to utf-8
http://php.net/manual/de/function.utf8-encode.php