I tried to search through SO but couldn't find a solution to this.
My iOS receive comment (NSString) from User and send it back to server via Http POST and then if user want to view that comment again the comment was sent back by Http get. And I display that in UILabel.
I can't seem to display the comment properly if it contained Emoji ( smiley,etc. )
When I typed emoji . The console show that data before posting to server is "\Ud83d\Ude1d" And when I got it back from my server via JSON it is this string "\Uf61d" . It shown just in box letter not a proper emoji.
Here is my code when sending it to server (NSUTF8Encoding)
NSDictionary *postDetailDict = [NSDictionary
dictionaryWithObjectsAndKeys:
itemID,@"item_id",
title,@"title",
nil];
for (NSString *param in postDetailDict) {
[body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", param] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"%@\r\n", [postDetailDict objectForKey:param]] dataUsingEncoding:NSUTF8StringEncoding]];
}
And when I received data back from HTTP GET . I just use
[commentObject setComment:[d objectForKey:@"comment"]];
[commentLabel setLabel:commentObject.comment];
Somebody please help. My server is on Heroku (Rails)
Thanks in advance
I found the solution. It is not related to front-end. It's about the way JSON returned from my rails server is not properly decoded. This workaround can solve this issue for those who has the same problem