我有两个在 UTF-8 中看起来完全相同的字符串。
$string1 = "histórico";
$string2 = "histórico";
但是当我将它们转换为 ISO-8859-1 时,(它不介意我使用 utf8_decode
、iconv
或 mb_convert_encoding
)我得到了不同的输出:
- string1 转换为 histoÌrico
- string2 转换为 histórico(实际上,这就是我对两个字符串的期望)
有什么想法吗?
提前致谢!
最佳答案
有two ways of creating the character ó
in Unicode :
- 作为单个字符:
U+00F3
- 作为小写
o
,后跟组合重音符号´
:U+006F U+0301
渲染后,它们看起来完全相同。
关于php - utf8_解码() : Same strings in UTF-8 returns different result (PHP),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28381650/