如何解码以“ \u”开头的内容用PHP

问题描述:

如何使用PHP解码以 \u开头的内容

How to decode something beginning with "\u" with PHP

例如

\u4f60\u5df2\u7ecf\u6dfb\u52a0\u4e86\u6b64\u8bdd\u9898

谢谢

使用PHP 5.4 / intl:

With PHP 5.4/intl:

$s = "\u4f60\u5df2\u7ecf\u6dfb\u52a0\u4e86\u6b64\u8bdd\u9898";
echo transliterator_transliterate("Hex-Any/Java", $s);

输出:

你已经添加了此话题

对于以前的版本,您可以采用此答案

For versions before, you can adapt this answer.

请注意,答案此处此处不处理补充字符(那些不能用一个代码单元表示的字符) (在UTF-16中)。

Note that the answers here and here don't deal with supplementary characters (those that cannot be represented with one code unit in UTF-16).