url encoding
Encode and Decode
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
Encode | Decode | unEncode | Unencode total |
encodeURIComponent :- >UTF-8 | decodeURIComponent | !, ‘,(,),*,-,.,_,~,0-9,a-z,A-Z | 71 |
encodeURI :- > UTF-8 | decodeURI | !,#,$,&,’,(,),*,+,,,-,.,/,:,;,=,?,@,_,~,0-9,a-z,A-Z | 82 |
escape :- > Unicode | unescape | *,+,-,.,/,@,_,0-9,a-z,A-Z | 69 |
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
评论
发表评论