后台请求需要把带有中文的参数转换GBK编码
+ (NSString *)convertStringToGBKStr:(NSString *)str {
NSMutableArray *array = [[NSMutableArray alloc]init];
///转换成gbk
NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
NSData*data = [strdataUsingEncoding:enc];
Byte*bytes = (Byte*)[databytes];
for(NSUIntegeri=0;i < data.length; i++) {
[arrayaddObject:[NSStringstringWithFormat:@"%%%X",bytes[i]]];
}
return [array componentsJoinedByString:@""];
}
当图片地址url中含有中文字符时,需要把URL字符串转码
NSString *url = [picURL stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
网友评论