How to encode URLs containing Unicode? I would like to pass it to a command line utility and I need to encode it first.
Example: http://zh.wikipedia.org/wiki/白雜訊
becomes http://zh.wikipedia.org/wiki/%E7%99%BD%E9%9B%9C%E8%A8%8A
.
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/白雜訊");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With