如何直接提交给后台,读取显示会乱码或者问号。一般需要先编码为base64,然后读取后解析为字符串即可正常显示。
需要使用第三方库:GTMBase64
编码:
NSData *data = [inputComment.text dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSString *encoded = [[NSString alloc]initWithData:[GTMBase64 encodeData:data] encoding:NSUTF8StringEncoding];
解码:
NSString* decoded = [[NSString alloc] initWithData:[GTMBase64 decodeString:commentModel.content] encoding:NSUTF8StringEncoding];
//content.text = commentModel.content;
content.text = decoded;