StringstrURL="";
try{
strURL=URLEncoder.encode(url,"utf-8");
}catch(UnsupportedEncodingExceptione){
//TODOAuto-generatedcatchblock
System.out.println("failed~");
e.printStackTrace();
}
strURL=strURL.replaceAll("%3A",":").replaceAll("%2F","/")
.replaceAll("%3F","?").replaceAll("%3D","=").replaceAll(
"%26","&");
:->3A-&>16*3+10-&>58-&>chr(58)=":"
/->2F-&>16*2+15-&>47-&>chr(47)="/"
-----------------------------------------------------
16*high bit + low bit
3A (hexadecimal) → 58 (decimal) → character (58) → display ":"
Encoding, not C++, this is to convert UTF8 to ANSI encoding.
Similar Posts:
- How to Solve TypeError: not all arguments converted during string formatting
- UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-1:
- [Solved] exception is java.lang.NoClassDefFoundError: com.sun.crypto.provider.SunJCE
- Transcoding of system.web.httputility.urlencode in C #
- [Solved] JAVA:java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcodbcDrive
- How to Solve JavaScript Error: replaceAll is not a function
- [How to Use] System.getProperty(“user.dir”)
- Java : Character decoding failed [How to Solve]
- Spring MVC upload file error string cannot be converted to multipartfile
- [Solved] Python Error: UnicodeDecodeError: ‘gb2312’ codec can’t decode byte 0xa4 in position… : illegal multibyte sequence