I m 要求第三方网站填写一份文本文件,其中我需要做一些细微的替换,以取代某些特性,例如,我需要用<代码>i通过í
取代某些特性。
Using string_replace/preg_replace_callback
on the response directly didn t result in matches (whether searching for í
directly or using its hex code x00xED
), so I used utf8_encode()
before carrying out the replacement. But utf8_encode
replaces all the í
characters by Ã
.
为什么出现这种情况,以及采用何种正确做法,利用营地任意更换UTF-8。
*编辑——一些进一步的研究显示
utf8_decode("í") == í;
utf8_encode("í") == ÃÂ;
utf8_encode("xc3xad") == ÃÂ;