3

I have an iPhone application in which I am sending text in an UITextview to a server through a web service. and in the next page I am displaying the list of comments from the server through the web service. Everything is working fine except when I insert emoji/emoticons in the UITextview.

The next page displays square boxes instead of some emoji character (not all).

I have noticed that:

  1. Working: I have inserted one emoji character in UITextview from an emoji keyboard and printed its code in log, \u2601, and submitted this text to the server. In the next page I got the same unicode \u2601 and it's working fine. It shows me the emoji icon.

  2. Not Working: Now I have inserted another emoji character in the UITextview from the emoji keyboard and printed its code in log, \ud83d\udc16, and submitted this text to the server. In the next page I got a unicode codepoint which is different from what I sent: \uf416. iPhone doesn't recognize this unicode so it gives me a square box.

So what is the problem here? It's not working only when the emoji character has a pair of unicode codepoints.

The database in which the comment is stored is MySQL version 5.5.

Why does the emoji character code pair change when retrieved from the server? How to decode the retrieved Unicode into its original form so iPhone can recognize it?

dda
  • 6,030
  • 2
  • 25
  • 34
Nignesh
  • 197
  • 1
  • 10

2 Answers2

0

The character U+F416 is in one of the Private Use Areas (PUA).

Likely, some code on the way from the app to the database and back replaced the emoji with this character. This could be any of the components on this way, e.g. the client library tha you use to communicate with the service, the web service, the database interface, or the database itself. Try to tackle each of this layers individually, or follow the character through the layers to check whether it is still correct.

oefe
  • 19,298
  • 7
  • 47
  • 66
0

Thanx Mar Byers, You gave me hint. I have read what is Unicode planes and what is surrogates and how it works. I have found that that is no server problem actually, because my SQL server version is 5.5 that has character set uyf8mb4, i have used that set in Comments column.

Now the problem with SBJSON that i used in my app to decode json response geting from server.SBJSON decode that surrogate pair(UTF16 UTF16) in one unicode UTF16, and thats why the emoji with surrogate pair is not displayed. Apple introduce json library NSJSONSerialization for ios5 and later os. I used that library to decode json response and my code work like charm..:)

I have got solution from here

http://blog.manbolo.com/2011/12/12/supporting-ios-5-new-emoji-encoding

and here

http://blog.manbolo.com/2012/10/29/supporting-new-emojis-on-ios-6

thanx to @Manbolo Blog.

Nignesh
  • 197
  • 1
  • 10