带有泰语的 NSURL
例如,我对 NSURL 和泰国语言有疑问 “http://www. xyp.com?var=ไทย" 它不起作用,但如果你使用 “http://www.xyp.com?var=Thai" 没关系。我不知道如何解决这个问题,请任何人帮助我。
I have problem with NSURL and Thailand language for example
"http://www.xyp.com?var=ไทย"
it does't work but if you use
"http://www.xyp.com?var=Thai"
it ok. I don't know how to solve this problem anyone please help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在 URL 字符串上使用了 stringByAddingPercentEscapesUsingEncoding 方法,它解决了问题,我使用的是丹麦字符
i used the method stringByAddingPercentEscapesUsingEncoding on the URL string, and it solved the problem, i was using Danish Characters
问题实际上出在 URI 的定义上。 RFC3986 将 URI 的内容以及扩展后的 URL 定义为 ASCII 字符,因此你必须以某种方式对它们进行编码。这就是百分比编码的全部内容。问题是没有人就编码哪些字节达成一致。 有些人更喜欢获取原始内容,将其转换为 UTF- 8,然后使用标准百分比编码对字节进行编码。其他人会简单地直接编码 UCS-2 字节,但你会遇到字节顺序问题。
您可能还想阅读 UNICODE URL 解码 帖子。
The problem is actually with the definition of a URI. RFC3986 defines the contents of a URI and, by extension, a URL as ASCII characters so you have to encode them somehow. This is what Percent encoding is all about. The problem is that no one agrees on what bytes to encode. Some people prefer to take the raw content, convert it into UTF-8, and then encode the bytes using standard percent encoding. Others will simply encode the UCS-2 bytes directly but then you have Byte order problems.
You might want to read the UNICODE URL Decoding posting as well.
NSURL 要求对所有特殊字符进行转义。
NSURL requires that all special characters be escaped.