NSString *emojiEscaped = @"\\ud83c\\udf81";
- (NSString*)decode:(NSString*)string{
NSData *emojiData = [string dataUsingEncoding:NSUTF8StringEncoding];
NSString *emojiString = [[NSString alloc] initWithData:emojiData encoding:NSNonLossyASCIIStringEncoding];
return emojiString;
}
- (NSString*)encode:(NSString*)string{
NSString *uniStr = [NSString stringWithUTF8String:[string UTF8String]];
NSData *uniData = [uniStr dataUsingEncoding:NSNonLossyASCIIStringEncoding];
NSString *goodStr = [[NSString alloc] initWithData:uniData encoding:NSUTF8StringEncoding] ;
NSLog(@"---编码--->[%@]",goodStr);
return goodStr;
}
网友评论