In addition to encodeuri (), encodeuriconponent (), and decodeuri () decodeuricomponent ()
Although not commonly used, it is very convenient to use in some cases. Definition and usage
The Unescape () function can decode strings encoded by escape.
Syntax
unescape(string)
Parameters |
Description |
String |
Required. The string to be decoded or reversed. |
Return Value
String is a decoded copy.
Description
This function works like this: Find the character sequence in the form of % XX and % uxxxx (X indicates a hexadecimal number ), use Unicode characters \ u00xx and \ uxxxx to replace such character sequences for decoding.
Tips and comments
Note: ecmascript V3 has removed the Unescape () function from the standard and is opposed to using it. Therefore, use decodeuri () and decodeuricomponent () instead.
Instance
In this example, we will use escape () to encode the string and then use Unescape () to decode it:
<script type="text/javascript">var test1="Visit W3School!"test1=escape(test1)document.write (test1 + "<br />")test1=unescape(test1)document.write(test1 + "<br />")</script>
Output:
Visit%20W3School%21Visit W3School!