1、把含有表情的字符串进行编码后再发送给服务端:
NSString *encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)urlString, (CFStringRef)@"!$&'()*+,-./:;=?@_~%#[]", NULL, kCFStringEncodingUTF8);
2、对从服务器获取回来含有表情的字符串进行反转后显示在页面上:
NSString *showText = [serverString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
3、把编码的字符串反转之后的显示效果图: