Section 24.78. escape( ): encode a string


24.78. escape( ): encode a string

ECMAScript v1; deprecated in ECMAScript v3

24.78.1. Synopsis

 escape(s) 

24.78.1.1. Arguments

s

The string that is to be "escaped" or encoded.

24.78.1.2. Returns

An encoded copy of s in which certain characters have been replaced by hexadecimal escape sequences.

24.78.2. Description

escape( ) is a global function. It returns a new string that contains an encoded version of s. The string s itself is not modified.

escape( ) returns a string in which all characters of s other than ASCII letters, digits, and the punctuation characters @, *, _, +, -, ., and / have been replaced by escape sequences of the form %xx or %uxxxx (where x represents a hexadecimal digit). Unicode characters \u0000 to \u00ff are replaced with the %xx escape sequence, and all other Unicode characters are replaced with the %uxxxx sequence.

Use the unescape( ) function to decode a string encoded with escape( ).

Although the escape( ) function was standardized in the first version of ECMAScript, it was deprecated and removed from the standard by ECMAScript v3. Implementations of ECMAScript are likely to implement this function, but they are not required to. You should use encodeURI( ) and encodeURIComponent( ) instead of escape( ).

24.78.3. Example

 escape("Hello World!");  // Returns "Hello%20World%21" 

24.78.4. See Also

encodeURI( ), encodeURIComponent( )




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net