我正在尝试使用 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编码。
您案例的有效 URL 是:http://xn--ls8h.la/
关于c# - 如何将 Process.Start() 与 unicode 符号(例如😜)一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32564080/