Tomas Tomas - 9 months ago 69
C# Question

Url Unicode characters encoding

How to encode URLs containing Unicode? I would like to pass it to a command line utility and I need to encode it first.



Answer Source

You can use the HttpUtility.UrlPathEncode method in the System.Web assembly (requires the full .NET Framework 4 profile):

var encoded = HttpUtility.UrlPathEncode("白雜訊");