I have a UITextView
which I call messageField
. The data within that messageField
is POST
-ed to server in JSON format. When th
I use the below code to encode emoji character
NSString *uniText = [NSString stringWithUTF8String:[textview.text UTF8String]];
NSData *msgData = [uniText dataUsingEncoding:NSNonLossyASCIIStringEncoding];
NSString *goodMsg = [[NSString alloc] initWithData:msgData encoding:NSUTF8StringEncoding] ;
And the below code to decode and display in UILabel
const char *jsonString = [body UTF8String];
NSData *jsonData = [NSData dataWithBytes:jsonString length:strlen(jsonString)];
NSString *goodMsg = [[NSString alloc] initWithData:jsonData encoding:NSNonLossyASCIIStringEncoding];