Url Unicode characters encoding

后端 未结 4 828
爱一瞬间的悲伤
爱一瞬间的悲伤 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:35

    Server.UrlEncode(s);
    

    .NET strings are natively Unicode strings (UTF-8 encoded, to be specific) so you need to nothing more than invoke HttpServerUtility.UrlEncode (though the so-called "intrinsic" Server property will be available in most contexts in asp.net where you may want to do this).

提交回复
热议问题