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

前端 未结 1 1485
北恋
北恋 2021-01-28 04:39

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

e.g.

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

thank you

相关标签:
1条回答
  • 2021-01-28 05:36

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

    0 讨论(0)
提交回复
热议问题