JavaScript (Urldecodedecodeuricomponent ()) This function name is too often, the individual really do not understand, after all, JS system functions are many, it is easy to miss. Trouble found this function by accident!
Encoding function: encodeURIComponent ()
decoding function: decodeURIComponent ()
decodeURIComponent () syntax
decodeURIComponent (uristring)
Parameters: (uristring) required. A string that contains the encoded URI component or other text to decode.
Return value: A copy of the uristring in which the hexadecimal escape sequence is replaced by the character they represent.
Example:
The code is as follows |
Copy Code |
<script type= "Text/javascript" > <! [cdata[ var test1= "annoyance";
var test2= "%E7%83%A6%E6%81%BC";
document.write ("code (formerly =" +test1+ "):" +encodeuricomponent (test1));
document.write ("Decoding (formerly =" +test2+ "):" +decodeuricomponent (test2)); ]]> </script>
|
Results:
Coding (original = annoyance):%E7%83%A6%E6%81%BC
Decoding (original =%E7%83%A6%E6%81%BC): Annoyance
Note: The test passes in the UTF-8 coding environment.