[英]How to use Process.Start() with unicode-Symbols (such as 😜)
我試圖使用Process.Start()
啟動帶有Unicode符號的URL,但它給出了一個Win32Exception:
An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
Additional information: Das System kann die angegebene Datei nicht finden
(英文:“系統找不到指定的文件”)
我試圖調用的URL是http://💩.la(這是一個有效的URL,至少對於Firefox 38而言)
在@Codo的建議之后我改變了我的代碼:
string link = "http://💩.la";
try
{
Process.Start(link);
}
catch (System.ComponentModel.Win32Exception)
{
Process.Start("IExplore.exe", link);
}
不要讓Firefox欺騙你。 URL中不允許使用ASCII碼以外的Unicode字符,尤其是表情符號; 他們需要編碼。 Firefox是用戶友好的,接受它們,顯示它們但在執行請求后自動對它們進行編碼。
如果Unicode字符在域名中,則需要進行Punycode編碼。 如果Unicode字符位於域名之后,則需要對其進行URL編碼。
您案例的有效網址是: http : //xn--ls8h.la/
試試這些:
http://xn--ls8h.la/(Punycode )
http://%F0%9F%92%A9.la/ (URL轉義碼)
看看RFC 3986 。 URL只能包含US-ASCII字符。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.