Additional JavaScript Global Functions
This topic describes some additional JavaScript global functions you can use.
escape() and unescape()
The JavaScript escape() and unescape() functions can be used to encode strings that contain characters with special meanings or outside the ASCII character set.
The escape() function encodes a string. This function makes a string portable, so it can be transmitted across any network to any computer that supports ASCII characters.
The function does not encode A-Z, a-z, and 0-9. Additionally, the function encodes all other characters with the exception of: "*", "@", "-", "_", "+", ".", "/".
The escape() function maps:
To:
encodeURI() and decodeURI()
The encodeURI() function is similar to the escape() function but encodes fewer character. Encoding the string:
Will produce:
%20!%22#$%25&'()*+,-./0123456789:;%3c=%3e?@ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~ |
So only the following characters are encoded:
SPACE, "“", "&", "<", ">", "[", "\", "]", "^", "`", "{", "|", "}"