UNICODE到ZH-CN

问题描述:

NSArray *array=[contentOfResponseDataInJsonValue JSONValue]; 
NSLog(@"%@",array); 

打印:UNICODE到ZH-CN

(
    (
     (
     "\U515c\U639b\U8e55", 
     AABENRAA, 
     " o b\U8c46n lu\U8eab" 
     ) 
    ), 
    (
    ), 
    en 
) 

if (array==nil) { 
    return [email protected]""; 
}else { 
    returnStr=[[[array objectAtIndex:0] objectAtIndex:0] objectAtIndex:0] ; 
} 
NSLog(@"result is %@",returnStr); 

显示:兜挂跸

\U515c\U639b\U8e55来兜挂跸为什么,为什么!

请帮帮我!!!谢谢!

+0

中国的两个部分相同的渲染我.. – Thanatos 2010-09-03 03:09:36

NSString *contentOfResponseDataInJsonValue = 
    [NSString stringWithContentsOfURL:url encoding:encoder=-2147483646 error:&error]; 
//            ^^^^^^^^^^^^^^^^^^^ 

这是什么?您使用的编码0x80000002在任何地方都没有记录。由于translate.google.com将返回UTF-8的结果,你应该写

NSString *contentOfResponseDataInJsonValue = 
    [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error]; 

或者让系统确定编码为你,

NSString *contentOfResponseDataInJsonValue = 
    [NSString stringWithContentsOfURL:url usedEncoding:&encoding error:&error]; 

我抬头的Unicode编码表,并确实

  • \U515c是兜,
  • \U639b是挂,
  • \U8e55是跸。

这三个字母的组合对我来说没有意义(作为日语),但这就是您在JSON数据中的含义。

你想做什么?为了得到帮助,你需要解释你想得到什么帮助。

+0

哦,对不起! NSString * strURL = [NSString stringWithFormat:@“http://translate.google.cn/translate_a/t?client=t&text=%@&hl=zh-CN&sl=%@&tl=%@&multires=1&otf=2&pc=0&sc = 1“,strTextOfFilter,@”en“,@”zh-CN“]; NSURL * url = [[NSURL alloc] initWithString:strURL]; NSString * contentOfResponseDataInJsonValue = [NSString stringWithContentsOfURL:url encoding:encoder = -2147483646 error:&error];的NSLog(@ “%@”,网址); 为什么我复制url在browser.return结果是[[“奥本罗”,“AABENRAA”,“Àběnluō”]],“en”]。 但NSLog(@“%@”,contentOfResponseDataInJsonValue); print [[“兜挂跸”,“AABENRAA”,“o b豆n lu身”]] ,,“en”]。 – raien 2010-09-03 03:52:01

+0

我还是不明白。请解释你想达到什么。发布“这段代码确实是A,那段代码没有B”并没有告诉我们你想做什么。 – Yuji 2010-09-05 03:27:50