美文网首页
UNICODE编码转表情

UNICODE编码转表情

作者: 今年27 | 来源:发表于2022-09-21 13:57 被阅读0次
     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;
    }
    

    相关文章

      网友评论

          本文标题:UNICODE编码转表情

          本文链接:https://www.haomeiwen.com/subject/bjgbortx.html