Ios JSON编码UTF-8字符串
如何从URL获取JSON并对NSString进行编码以使用NSLog显示? JSON包含中文单词Ios JSON编码UTF-8字符串,ios,objective-c,xcode,utf-8,Ios,Objective C,Xcode,Utf 8,如何从URL获取JSON并对NSString进行编码以使用NSLog显示? JSON包含中文单词 NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:@"http://jxdp.mnks.cn/read.php?xCode=6beff&Code=6beff&Type=1&&top=5&min=0&am
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://jxdp.mnks.cn/read.php?xCode=6beff&Code=6beff&Type=1&&top=5&min=0&CALL="]];
[request setHTTPMethod:@"GET"];
NSURLResponse *requestResponse;
NSData *requestHandler = [NSURLConnection sendSynchronousRequest:request returningResponse:&requestResponse error:nil];
NSString *requestReply = [[NSString alloc] initWithBytes:[requestHandler bytes] length:[requestHandler length] encoding:NSUTF8StringEncoding];
NSLog(@"requestReply: %@", requestReply);
也许这对你有帮助,你想用中文解析和记录JSON响应。通常,您不能依赖NSLog来显示扩展字符,尽管如果不显示实际字符,它将显示有效的转义符。这不会以任何方式影响在适当的文本视图中显示的内容。