NSURL 任何时候都不起作用
我遇到以下问题,有时我的 openURL-Dialog 工作得很好,然后我查看了 url 中的变量,这就是变量:
www.brehm-gmbh.de
但有时变量末尾有一些疯狂的元素,如下所示:
www.adamczyk-fenster.de%E2%80%8E
我得到此页面来自 .asc 文件,并且在没有此元素的情况下,两者都在此文件中正常, 我能做什么来解决这个问题?
谢谢大家事先的帮助
i have the following problem sometimes my openURL-Dialog works perfectly, then i looked at the variable from the url and that is the variable:
www.brehm-gmbh.de
but some other times there are some crazy elements at the end of the variable like this:
www.adamczyk-fenster.de%E2%80%8E
i get this pages from an .asc file and both are in this file normal without this elements,
what can i do to solve this problem?
thank you all for helping beforehand
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自维基百科:
您收到此消息是因为 (1) 您有非英语 URL,正在从非英语字符串组成 URL,或者您有一些其他非英语元素,并且字符串编码正在尝试补偿,或者 (2) 它是垃圾解释为编码(如果一致则不太可能。)
在使用字符串之前调用
-[NSString localizedNameOfStringEncoding]
查看它正在使用的编码。在将字符串放入 NSURL 之前读取字符串时,您可能需要显式建立编码。From Wikipedia:
You're getting this because (1) you've got non-English URLs, are composing URLs from non-English strings or you have some other non-English elements and the string encoding is attempting to compensate or (2) it's garbarge being interpreted as an encoding (unlikely if it is consistant.)
Call
-[NSString localizedNameOfStringEncoding]
on the string before you use it see what encoding it is using. You probably need to explicitly establish an encoding when you read in the strings before you put them in the NSURL.