4 回答
Perhaps database uses different encoding than your PHP file. Start with comparing those strings converted with bin2hex()
function (in PHP).
Second attempt:
There are a bunch of suggestions in the PHP doc's comments. Try these:
- http://www.php.net/manual/es/function.str-replace.php#106653
- http://www.php.net/manual/es/function.str-replace.php#75566
- http://www.php.net/manual/es/function.str-replace.php#72344
Try explicitly setting your page's chartype. Try placing this in the header:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Or, if you're using HTML 5:
<meta charset="utf-8">
I think since you have some weird characters they might go beyond ascii range and you might need to use multibyte string functions, though it does not have str_replace analogue, you might need to use multibyte regexes.
please take a look at this , it will tell you how to handle UTF characters in a web app