I'm studying Objective-C.When my project need transcoding emoji ,I don't know how to deal with it.
The Requirement are follow:
1.when user send their comment , I should transcoding emoji to a string like unicode or utf-8 cause our server don't store emoji.
2.when user load comment data ,I should transcoding string to a emoji which was System comes (now is iOS 10 which have National flag cost 4 btyes) .And present emoji in device.
Before saving the comment to server use the below code
NSData *dataForEmoji = [comment dataUsingEncoding:NSNonLossyASCIIStringEncoding]; NSString *encodevalue = [[NSString alloc]initWithData:dataForEmoji encoding:NSUTF8StringEncoding];
Save the encodedvalue to your server.
When you retrieve use below code before you display
NSString *emojiText = [NSString stringWithCString:[textFromServer cStringUsingEncoding:NSUTF8StringEncoding] encoding:NSNonLossyASCIIStringEncoding];