url encoding

Encode and Decode

EncodeDecodeunEncodeUnencode total
encodeURIComponent :- >UTF-8decodeURIComponent !, ‘,(,),*,-,.,_,~,0-9,a-z,A-Z71
encodeURI :- > UTF-8decodeURI !,#,$,&,’,(,),*,+,,,-,.,/,:,;,=,?,@,_,~,0-9,a-z,A-Z82
escape :- > Unicodeunescape  *,+,-,.,/,@,_,0-9,a-z,A-Z69

javascript example :

  encodeURIComponent in Javascript 1.5


  alert(encodeURIComponent("ö / ! * ( ) ' "));

Java example :

       System.out.println("java.net.UrlEncoder(\"ö\",\"UTF8\"): =" +java.net.URLEncoder.encode("ö","UTF8"));

      java.net.URLDecoder urlDecoder = new java.net.URLDecoder();
       String s =  urlDecoder.decode("%D0%C5%CF%A2%CD%F8","gb2312");
       System.out.println(s);
       s =  urlDecoder.decode("D0%C5%CF%A2%CD%F8","utf8");
       System.out.println(s);      

JSP:
String sZ = java.net.URLEncoder.encode("中", "utf-8");
action="s.jsp?z=<%=sZ%>">
String zhongguo=new String(request.getParameter("sZ").getBytes("iso8859_1"));
zhongguo=java.net.URLDecoder.decode(sZ,"utf-8");
String tmpS = URLEncoder.encode(tipC.trim(),"UTF-8");
           tmpS = tmpS.replaceAll("\\+",  " ");  // +
//Get local encoding
final String encoding = System.getProperty("file.encoding");

.Net Core
System.Uri.EscapeUriString  <==> decodeURIComponent
Ref:
https: / / briancaos.wordpress.com/2009/03/31/decodeuricomponent-equivalent-in-c/
https: / / stackoverflow.com/questions/4396598/whats-the-difference-between-escapeuristring-and-escapedatastring

评论

此博客中的热门博文

XML, XSL, HTML

Input in element.eleme.io

Data URI是由RFC 2397 ACE