escape
Returns the hexadecimal encoding of an argument in the ISO-Latin-1 character set.
Core function
Syntax
escape( "string" )
Parameters
Parameter | Description |
---|---|
string | A string in the ISO-Latin-1 character set. |
Description
escape is a top-level function and is not associated with any object.
Use the escape and unescape functions to encode and decode (add property values manually) a Uniform Resource Locator (URL), a Uniform Resource Identifier (URI), or a URI-type string.
The escape function encodes special characters in the specified string and returns the new string. It encodes spaces, punctuation, and any other character that is not an ASCII alphanumeric character, with the exception of these characters:
* @ - _ + . /
Unicode
The escape and unescape functions do not use Unicode as specified by the MetaScript specification. Instead, they use the Internet Engineering Task Force (IETF) guidelines for escaping characters. Within a URI, characters use US-ASCII characters (ISO-Latin-1 character set). A URI is a sequence of characters from the basic Latin alphabet, digits, and a few special characters (for example, / and @). The escape sequences do not support \uXXXX as in Unicode or %uXXXX as specified by ECMA, but %XX, where XX is a 2-digit hexadecimal number (for example, %7E). In URI, characters are represented in octets, as 8-bit bytes.
To allow the escape and unescape functions to work with Web server-supported URLs and URIs, MetaScript does not use Unicode for these functions.
- escape returns the hexadecimal encoding of the specified string in the ISO-Latin-1 character set.
- unescape returns the ASCII string, an ISO-Latin-1 character set sequence.
Unicode-specific escape sequences, %uXXXX, are not supported.
Examples
Example 1. The following example returns "%26":
Example 2. The following statement returns a string with encoded characters for spaces, commas, and apostrophes.