I am working on an iPhone app which allows people to send messages with Emoji icons. I saved the icon in Mysql with charset utf8mb4 and collation utf8mb4_unicode_ci, and all the emoji icons is saved correctly in my database. However, when I return json back to the client (php json_encode), the Emoji is encoded as something like this: '\ud83d\ude04', and iPhone displays it as a square. However, if I return as XML, the Emoji Icon won't become unicode like this: '\ud83d\ude04', it will just be the icon.
I am wondering if this is an issue on my server, or on my client. If it is my client, how can object c decode it correctly.
Can someone please help?
Thanks
"\ud83d\ude04"
is the JSON Unicode escape sequence forU+D83D U+DE04
, which is the "surrogate pair" for the Unicode U+1F604 (SMILING FACE WITH OPEN MOUTH AND SMILING EYES).But
NSJSONSerialization
decodes this correctly, as can be seen in the following example:Output:
Our team fixed this problem by transfer utf data to server, saving them in mysql utf8mb4 codepage and receiving with base64. Server convert saved data to base64 on demand.
Please follow following steps:
Note: When you want to Show on webPage then Decode data when you display data on WebPage.