Url Unicode字符编码 [英] Url Unicode characters encoding
本文介绍了Url Unicode字符编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何对包含Unicode的URL进行编码?我想把它传递给命令行工具,我需要先编码它。
How to encode URLs containing Unicode? I would like to pass it to a command line utility and I need to encode it first.
示例: http://zh.wikipedia。 org / wiki /白杂讯
成为 http://zh.wikipedia.org/wiki/%E7 %99%BD%E9%9B%9C%E8%A8%8A
。
推荐答案
可以使用 HttpUtility.UrlPathEncode
方法在 System.Web
程序集中(需要完整的.NET Framework 4配置文件):
You can use the HttpUtility.UrlPathEncode
method in the System.Web
assembly (requires the full .NET Framework 4 profile):
var encoded = HttpUtility.UrlPathEncode("http://zh.wikipedia.org/wiki/白雜訊");
这篇关于Url Unicode字符编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文