Java and .net difference of about URL Encode

In c #, HttpUtility.UrlEncode ( "www + mzwu + com") coding results www% 2bmzwu 2bcom%, and in the development of the Java platform to do when the docking, the other with a MD5 encrypted with them and then url encoded, url after a string of coded as big (www% 2Bmzwu% 2Bcom) write out a string of such encryption would not match the .net platform,

solution:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public  string  UrlEncode( string  str)
{
     StringBuilder builder =  new  StringBuilder();
     foreach  ( char  in  str)
     {
         if  (HttpUtility.UrlEncode(c.ToString()).Length > 1)
         {
             builder.Append(HttpUtility.UrlEncode(c.ToString()).ToUpper());
         }
         else
         {
             builder.Append(c);
         }
     }
     return  builder.ToString();
}

Guess you like

Origin www.cnblogs.com/Alex80/p/11532664.html