Table of Contents

escape( ) Global Function Flash 6

encode a string for safe network transferFlash 5; enhanced to support UTF-8 in
escape(string)

Arguments

string

A string (or an expression that yields a string) to be encoded.

Returns

An encoded version of string.

Description

The escape( ) function creates a new encoded string, based on a supplied string. The new string contains a hexadecimal escape sequence in place of any character in the supplied string that is not a digit or a basic, unaccented Latin letter between A and Z or a and z. As of Flash Player 6, the replacement hexadecimal escape sequences take the following format:

Flash Player 5 behaves as if System.useCodepage is always true (earlier versions did not support escape( )).

The escape( ) function is sometimes used when a Flash movie sends information to server applications or writes cookies in a browser. To decode an encoded string, use the global unescape( ) function.

Usage

Note that for characters above Unicode code point U+007F (decimal 127), the UTF-8 escape sequence is not the same number as the Unicode code point! For example, the code point for é is U+00E9 (decimal 233), but the UTF-8 sequence is %C3%A9. See the LoadVars class for information on loading external encoded text.

Example

trace(escape("6-5 is 4"));  // Displays: 6%2D5%20is%204  (- is %2D, space is %20)
trace(escape("resumé"));    // Displays: resum%C3%A9

See Also

unescape( ); Appendix B


Table of Contents