Url Unicode characters encoding

后端 未结 4 821
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-13 00:12

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/白

4条回答
  •  耶瑟儿~
    2021-01-13 00:22

    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/白雜訊");
    

提交回复
热议问题