PHP - 如何将“\xea”之类的字符转换为正确的“ê”字符? (ISO-88591 - 重音)

PHP - How convert chracters like "\xea" to correct "ê" character? (ISO-88591 - accented)

我在一篇文章中有很多字符 / json 比如:

\xea = ê
\xaa = ª (I think)

如何转换为 PHP 中的正确字符?

非常感谢。

您可以尝试这样的操作:

$text = preg_replace_callback('/\\x([0-9a-fA-F]{2})/', function ($matches) { return chr(hexdec($matches[1])); },$text);

编辑:抱歉,我只是 copy/pasted 旧代码 - e 修饰符已弃用。