Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

Example: http://zh.wikipedia.org/wiki/白雜訊

becomes http://zh.wikipedia.org/wiki/%E7%99%BD%E9%9B%9C%E8%A8%8A.

like image 881
Tomas Avatar asked Sep 07 '11 13:09

Tomas


1 Answers

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/白雜訊");
like image 198
Martin Liversage Avatar answered Nov 15 '22 02:11

Martin Liversage