Get string from Server.UrlEncode as uppercase

前端 未结 5 1199
忘掉有多难
忘掉有多难 2021-01-08 00:35

I want its output as uppercase. This is what I get on Server.UrlEncode(\"http://\"):

http%3a%2f%2f

but I need:

<         


        
5条回答
  •  伪装坚强ぢ
    2021-01-08 01:07

    This will uppercase all escaped characters in your string.

    string url = "http://whatever.com/something";
    string lower = Server.UrlEncode(url);
    Regex reg = new Regex(@"%[a-f0-9]{2}");
    string upper = reg.Replace(lower, m => m.Value.ToUpperInvariant());
    

提交回复
热议问题