URL transcoding (including Chinese): 3A to ‘:’,% 2F to ‘/’

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: