我试图将表情符号转换为unicode字符。我尝试使用此解决方案中建议的第二个选项:iOS 5: How to convert an Emoji to a unicode character? 但我的tableviewcell标签中的输出看起来像这样: \ ud83d \ ude0b 以下是保存评论的代码:
NSData *dataString = [body dataUsingEncoding:NSNonLossyASCIIStringEncoding];
NSString *goodValue = [[NSString alloc] initWithData:dataString encoding:NSUTF8StringEncoding];
NSDictionary *parameters = @{ @"body" : goodValue };
//and so forth it is saved to the cloud
这是转换回表情符号的过程:
NSData *data = [self.comment.body dataUsingEncoding:NSNonLossyASCIIStringEncoding];
NSString *goodValue = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
self.bodyLabel.text = goodValue;