1、把含有表情的字符串進(jìn)行編碼后再發(fā)送給服務(wù)端:
NSString *encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)urlString, (CFStringRef)@"!$&'()*+,-./:;=?@_~%#[]", NULL, kCFStringEncodingUTF8);
2哼蛆、對(duì)從服務(wù)器獲取回來含有表情的字符串進(jìn)行反轉(zhuǎn)后顯示在頁(yè)面上:
NSString *showText = [serverString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
3、把編碼的字符串反轉(zhuǎn)之后的顯示效果圖: