开发者

unicode to zh-cN

开发者 https://www.devze.com 2023-01-15 03:42 出处:网络
NSArray *array=[contentOfResponseDataInJsonValue JSONValue]; NSLog(@\"%@\",array); prints: ( ( ( \"\\U515c\\U639b\\U8e55\",
NSArray *array=[contentOfResponseDataInJsonValue JSONValue];
NSLog(@"%@",array); 

prints:

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

but

if (array==nil) {
    return returnStr=@"";
}else {
    returnStr=[[[array objectAtIndex:0] objectAtIndex:0] ob开发者_高级运维jectAtIndex:0] ;
}
NSLog(@"result is %@",returnStr);

show :兜掛蹕

\U515c\U639b\U8e55 to 兜掛蹕 why ,why!

please help me !!! thanks!


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

What is this? You are using the encoding 0x80000002 which is not documented anywhere. Since translate.google.com is returning UTF-8 result, you should write

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

or let the system determines the encoding for you,

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


I looked up the Unicode table, and indeed

  • \U515c is 兜 ,
  • \U639b is 掛 ,
  • \U8e55 is 蹕 .

The combination of those three letters doesn't make sense to me (as a Japanese), but that's what you have in JSON data.

What do you want to do? In order to be helped, you need to explain about what you want to be helped.

0

精彩评论

暂无评论...
验证码 换一张
取 消