json_decode emoji gives strange characters like: ðY'' [duplicate]

孤街浪徒 提交于 2019-12-11 10:44:02

问题


I am receiving messages from Facebook Messenger to my PHP server.

I json_decode the request like this:

$facebookRequest = json_decode( file_get_contents('php://input'), true );

After that, the emojis in the text all come out as these strange characters, and not as Hex or Unicode formats.

The characters don't even post correctly here so here is a screenshot of them:
that's from a simple smiley face.

Now I can reverse the text through json_encode then I get: \u00f0\u009f\u0098\u0080.

Is there a better way to handle emojis passing through json_decode?


回答1:


Try rawurlencode or decode methods before passing to json_ decode.

http://php.net/manual/en/function.rawurlencode.php



来源:https://stackoverflow.com/questions/51798486/json-decode-emoji-gives-strange-characters-like-%c3%b0y

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!