EncodeURIComponent
Encodes a text string into a valid component of a uniform resource identifier (URI.
EncodeURIComponent (encodedURIString)
The required encodedURIString parameter represents an encoded URI component.
Description
The encodeURIComponent method returns an encoded URI. If you pass the encoding result to decodeURIComponent, the initial string is returned. Because the encodeURIComponent method encodes all characters, note that if the string represents a path, for example,/folder1/folder2/default.html, the Slash will also be encoded. In this way, when the encoding result is sent to the web server as a request, it will be invalid. If the string contains more than one URI component, use the encodeURI Method for encoding.
Escape Method
Returns an encoded String object that can be read on all computers.
Function escape (charString: String): String
Parameters
CharString
Required. Any String object or text to be encoded.
Remarks
The escape method returns a string containing charstring content (in Unicode format ). All spaces, punctuation marks, accents, and any other non-ASCII characters are replaced by % xx encoding, where xx equals to the hexadecimal number of the character. For example, a space is returned as "".
Characters with a character value greater than 255 are stored in % uxxxx format.
Note that the escape method cannot be used to encode the Uniform Resource Identifier (URI. Use the encodeURI and encodeURIComponent methods for encoding.
Requirements
Version 1
See
EncodeURI method | encodeURIComponent method | String object | Method
Applicable to: Global Objects
EncodeURI Method
Returns a string encoded as a valid Uniform Resource Identifier (URI.
Function encodeURI (URIString: String): String
Parameters
URIString
Required. Indicates the URI-encoded string.
Remarks
The encodeURI method returns an encoded URI. If the encoding result is passed to decodeURI, the initial string is returned. EncodeURI does not encode the following characters: ":", "/", ";", and "?". Use encodeURIComponent to encode these characters.
Requirements
Release 5.5
See
DecodeURI method | decodeURIComponent Method
Applicable to: Global Objects
EncodeURIComponent Method
Returns the string of a valid component encoded as a uniform resource identifier (URI.
Function encodeURIComponent (encodedURIString: String): String
Parameters
EncodedURIString
Required. Indicates the string that encodes the URI component.
Remarks
The encodeURIComponent method returns an encoded URI. If the encoding result is passed to decodeURIComponent, the initial string is returned. The encodeURIComponent method encodes all characters. Note that if the string represents a path, for example,/folder1/folder2/default.html, the Slash will also be encoded, when this string is sent to the Web server as a request, it will be invalid. If the string contains multiple URI components, use the encodeURI Method for encoding.
Requirements
Release 5.5
See
DecodeURI method | decodeURIComponent Method
Applicable to: Global Objects
Method
Returns the decoded String from the String object encoded using the escape method.
Function (charString: String): String
Parameters
CharString
Required. String object or text to be decoded.
Remarks
Returns a string that contains charstring content. All characters encoded in % xx hexadecimal format are replaced by equivalent characters in the ASCII character set.
Characters encoded in % uxxxx format (Unicode character) are replaced by Unicode characters encoded in hexadecimal format xxxx.
Note that the method should not be used to decode the Uniform Resource Identifier (URI ). Use the decodeURI and decodeURIComponent methods.
Requirements
Version 1
See
DecodeURI method | decodeURIComponent method | escape method | String object
Applicable to: Global Objects
DecodeURI Method
Returns the unencoded format of an encoded Uniform Resource Identifier (URI.
Function decodeURI (URIstring: String): String
Parameters
URIstring
Required. Indicates the URI-encoded string.
Remarks
Use the decodeURI method to replace outdated methods.
The decodeURI method returns a string value.
If URIString is invalid, A URIError occurs.
Requirements
Release 5.5
See
DecodeURIComponent method | encodeURI Method
Applicable to: Global Objects
DecodeURIComponent Method
Returns the non-encoding form of an encoded component of the Uniform Resource Identifier (URI.
Function decodeURIComponent (encodedURIString: String): String
The required encodedURIString parameter is the value of an encoded URI component.
Remarks
URIComponent is part of a complete URI.
If encodedURIString is invalid, A URIError is generated.
Requirements
Release 5.5
See
DecodeURI method | encodeURI Method
[Html] <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ptml xmlns = "http://www.w3.org/1999/xhtml"> <pead> <title> Js encode, decode </title> <meta http-equiv = "Content-Type" content = "text/html; charset = gb2312 "/> </pead> <body> <pre class =" code "id = code cols = 80 rows = 20> </textarea> <br> <input type = button onclick = encode () value = encoding> <input type = button onclick = run () value = Execution> <input type = button onclick = decode () value = decoding> </body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
[/Html]
For more information, see the following reference manual for JavaScript global objects.