我有一个用作浏览器的 wkwebview。我无法加载带有特殊字符的地址,例如“ http://www.håbo.se ”(瑞典字符)。
我在用着:
parsedUrl = [parsedUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
这是有希望的,因为它创建了一个如下所示的地址: http://www.h%c3%a5bo.se/
如果我在 Chrome 中输入它,它就可以工作。但是当我尝试在 wkwebview 中加载它时,我得到以下信息(我可以加载所有其他页面):
这是打印的完整 NSError
Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={_WKRecoveryAttempterErrorKey=<WKReloadFrameErrorRecoveryAttempter: 0x7f82ca502290>, NSErrorFailingURLStringKey=http://www.h%c3%a5bo.se/, NSErrorFailingURLKey=http://www.h%c3%a5bo.se/, NSUnderlyingError=0x7f82ca692200 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "A server with the specified hostname could not be found." UserInfo={NSErrorFailingURLStringKey=http://www.h%c3%a5bo.se/, NSErrorFailingURLKey=http://www.h%c3%a5bo.se/, _kCFStreamErrorCodeKey=8, _kCFStreamErrorDomainKey=12, NSLocalizedDescription=A server with the specified hostname could not be found.}},