如何在UIWebView中打开西里尔文字域? [英] How to open cyrillic domain in UIWebView?
问题描述
我尝试在UIWebView中打开cyrillic url,但它可以打开。
我使用以下代码%
I try to open cyrillic url in UIWebView, but it's can open. I use the following code%
urlString = [NSString stringWithFormat:@"http://%@", urlString];
urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
url = [NSURL URLWithString:urlString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[_webView loadRequest:request];
如果我尝试打开 https://www.google.ru/webhp?q =президент#newwindow = 1& q =президент一切正常,但当我尝试打开президент.рф时,它是不起作用。
我需要为开放的西里尔文域做些什么?
If i try to open https://www.google.ru/webhp?q=президент#newwindow=1&q=президент everything is OK, but when I try to open президент.рф it's doesn't work. What I need to do for open cyrillic domain?
推荐答案
要连接到IDN(国际域名)网址,你需要在Punycode中对它们进行编码。例如,此网址将编码为 http://xn--d1abbgf6aiiy.xn--p1ai 。
To connect to IDN (international domain name) URLs, you need to encode them in Punycode. For example, this URL would be encoded as http://xn--d1abbgf6aiiy.xn--p1ai.
不幸的是,我不知道iOS中有任何内置的punycode支持。但是有第三方工具,如 NSURL-IDN (摘自 OmniNetworking 库。)
Unfortunately I don't know of any built-in punycode support in iOS. But there are third-party tools like NSURL-IDN (which is extracted from the OmniNetworking library).
这篇关于如何在UIWebView中打开西里尔文字域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!