开发者

NSURL with Thai language

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开发者_C百科 problem anyone please help me.


i used the method stringByAddingPercentEscapesUsingEncoding on the URL string, and it solved the problem, i was using Danish Characters


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 requires that all special characters be escaped.


try url-encode
search the key word "url encode" and you can find some websites like https://www.urlencoder.org/

Then http://www.xyp.com?var=ไทย will be encoded into something like this

http%3A%2F%2Fwww.xyp.com%3Fvar%3D%E0%B9%84%E0%B8%97%E0%B8%A2

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜