对于UITextField或者UITextView,对于系统表情在发送服务器前做编码处理,示例代码如下:
NSCharacterSet *allowedCharacters = [NSCharacterSet characterSetWithCharactersInString:@"!$&'()*+,-./:;=?@_~%#[]"];
NSString *inputText = [self.originalTextView.text stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters];
显示时转码后显示,示例代码如下:
NSCharacterSet *allowedCharacters = [NSCharacterSet characterSetWithCharactersInString:@"!$&'()*+,-./:;=?@_~%#[]"];
NSString *showText = [inputText stringByRemovingPercentEncoding];