At this time, encodeURIComponent and decodeURIComponent appeared, which can completely encode and decode URLs. However, when encountering partial transcoding used by search engines, for example, it is difficult to find the door. No problem, PHP officially has a solution:
decodeURIComponent((str '').replace(/ / g, ' '));
It can perfectly decode the address of the search engine, because the search engine is only used to transcoding "spaces". Forgot to mention that I am also used to transcoding Chinese. . .
Then all the above solutions collapsed when encountering Chinese. Yes, I also collapsed. It was partially encoded and it was Chinese. . This makes me feel so embarrassed. . .
It’s okay to look it up for a long time, so I won’t say too much so you understand. . .
This is only for those that support VB Browser support. . . For example, FF does not support it. . .
Why use VB? Because methods like str2asc and asc2str cannot be satisfied by JS. . . Below I simulated two JS methods, which do not seem to be valid for all Chinese languages. .
function str2asc(str){
return str. charCodeAt(0).toString(16);
}
function asc2str(str){
return String.fromCharCode(str);
}