How to decode something beginning with “\\u” with

2020-05-02 08:56发布

问题:

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

e.g.

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

thank you

回答1:

With PHP 5.4/intl:

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

Output:

你已经添加了此话题

For versions before, you can adapt this answer.

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).