Java Reference
In-Depth Information
Encoded URI: http://www.jdojo.com/hi%20there
Decoded URI: http://www.jdojo.com/hi there
The decodeURIComponent( ) Function
The decodeURIComponent() function has the following signature:
decodeURIComponent(encodedURIComponent)
The decodeURIComponent() function is used to replaces the escape sequences in the
URI components (values in the URI's query part) with the corresponding characters. For
example, %26 needed to be used as an escape sequence in the value for an ampersand.
This function will convert %26 to an ampersand. The following code shows how to use
this function:
var encodedUriComponent = "Ken%26Donna";
var decodedUriComponent = decodeURIComponent(encodedUriComponent);
print("Encoded URI Component:", encodedUriComponent);
print("Decoded URI Component:", decodedUriComponent);
Encoded URI Component: Ken%26Donna
Decoded URI Component: Ken&Donna
The encodeURI( ) Function
The encodeURI() function has the following signature:
encodeURI(uri)
It returns uri after replacing certain characters with escape sequences. The following
code encodes a URI that contains a space. The space character is encoded as %20.
var uri = " http://www.jdojo.com/hi there";
var encodedUri = encodeURI(uri);
print("URI:", uri);
print("Encoded URI:", encodedUri);
URI: http://www.jdojo.com/hi there
Encoded URI: http://www.jdojo.com/hi%20there
 
 
Search WWH ::




Custom Search