There are these functions:
The decode ones does the reverse of encode.
Use “encodeURI” to encode a URI that contains non-ASCII characters.
For example, if the input string is
http://en.wikipedia.org/wiki/Sylvester–Gallai_theorem, containing a en-dash, Unicode 8211 (U+2013).
The result is:
The result can be used in a HTML link, example
%E2%80%93 is hexadecimals E2 80 93. It is the byte sequence of the en-dash char by UTF-8 encoding. This encoding is called percent encoding. It is required for all Unicode chars in the URI. (but usually browsers can handle it fine without percent encoding.)
“encodeURIComponent” is like “encodeURI”, but it also encodes the slash and other characters in URI.
“encodeURIComponent” is useful if you want to embed a URI as a parameter inside a URI. Example:
<a href="http://example.com/url?url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FSylvester%E2%80%93Gallai_theorem">Sylvester–Gallai theorem</a>
The “escape” seems to be a old function that doesn't have a clear purpose. Here's its result.
See also: Sample Unicode Characters.