首页 > 代码库 > emjio表情转json
emjio表情转json
今天碰到了上传文字给服务端的时候emjio表情转成json就不对了
有大神帮忙解决了,记笔记记笔记---
#import "NSString+EncodedString.h"
@implementation NSString (EncodedString)
+(NSString *)decodeString:(NSString*)encodedString
{
//NSString *decodedString = [encodedString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding ];
NSString *decodedString = (__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL,
(__bridge CFStringRef)encodedString,
CFSTR(""),
CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding));
return decodedString;
}
+(NSString*)encodeString:(NSString*)unencodedString{
// CharactersToBeEscaped = @":/?&=;+!@#$()~‘,*";
// CharactersToLeaveUnescaped = @"[].";
NSString *encodedString = (NSString *)
CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(CFStringRef)unencodedString,
NULL,
(CFStringRef)@"!*‘();:@&=+$,/?%#[]",
kCFStringEncodingUTF8));
return encodedString;
}
@end
//转json时
+(NSString *)decodeString:(NSString*)encodedString;
//从json转时
+(NSString*)encodeString:(NSString*)unencodedString;
主要是换了编码方式
emjio表情转json