Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios JSON编码UTF-8字符串_Ios_Objective C_Xcode_Utf 8 - Fatal编程技术网

Ios JSON编码UTF-8字符串

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

如何从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&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来显示扩展字符,尽管如果不显示实际字符,它将显示有效的转义符。这不会以任何方式影响在适当的文本视图中显示的内容。