How to convert Emoji from Unicode in PHP?

后端 未结 2 2068
南笙
南笙 2020-12-05 23:57

I use this table of Emoji and try this code:


2条回答
  •  伪装坚强ぢ
    2020-12-06 00:19

    PHP 5

    JSON's \u can only handle one UTF-16 code unit at a time, so you need to write the surrogate pair instead. For U+1F600 this is \uD83D\uDE00, which works:

    echo json_decode('"\uD83D\uDE00"');
    

提交回复
热议问题