gpt4 book ai didi

iphone - 重音符号的 NSString 编码显示疯狂字符

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:51:43 25 4
gpt4 key购买 nike

我正在从服务器下载数据(文本)。

我已经尝试过:NSISOLatin1StringEncodingNSASCIIStringEncoding

但我一直看到类似这样的东西:{"estado":"M\u00e9xico"}

注意它应该读作 México 而不是 M\u00e9xico(e 上有重音)。

在线查看我发现 \u00e9 实际上是 é link.

但 NSString 无法解释这一点,而是在我的 UILabels 上打印奇怪的东西:

enter image description here

非常感谢您对此提供的帮助。

此外,如果您有兴趣,可以从这里下载数据:http://www.miorden.com/demo/iphone/estadoJSON.php

NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.miorden.com/demo/iphone/estadoJSON.php"]];

NSString *string = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];

NSLog(@"Downloaded: %@", string);

string = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.miorden.com/demo/iphone/estadoJSON.php"] encoding:NSISOLatin1StringEncoding error:nil];

NSLog(@"Downloaded: %@", string);

我真的已经尝试了好几天了,但它要了我的命!

非常感谢!

最佳答案

这似乎是 unicode,试试 NSUTF8StringEncoding。

关于iphone - 重音符号的 NSString 编码显示疯狂字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7005981/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com