please dont rip this site

JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

escape() Function

Name

escape() Function---encode a string for transmission

Availability

Navigator 2.0, Internet Explorer 3.0

Synopsis

escape(s)

Arguments

s

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

Returns

An encoded copy of s.

Description

The escape() function is a built-in part of JavaScript; it is not a method of any object.

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

The string is encoded as follows: all spaces, punctuation, accented characters, and any other characters that are not ASCII letters or numbers are converted to the form %xx, where xx is two hexadecimal digits that represent the ISO-8859-1 (Latin-1) encoding of the character. For example, the ! character has the Latin-1 encoding of 33, which is 21 hexadecimal, so escape() replaces this character with the sequence %21. Thus the expression:

escape("Hello World!");

yields the string:

Hello%20World%21

The purpose of the escape() encoding is to ensure that the string is portable to all computers, and transmittable across all networks, regardless of the character encodings the computers or networks support (as long as they support ASCII, however).

The encoding performed by escape() is like the standard URL-encoding used to encode query strings and other portions of a URL that might include spaces, punctuation, or characters outside of the standard ASCII character set. The only difference is that in the URL encoding, spaces are replaced with a `+' character, while escape() replaces spaces with the %20 sequence.

Usage

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

A common use of escape() is to encode cookie values, which have restrictions on the punctuation characters they may contain. See "Document.cookie".

See Also

"String", "unescape()"


Previous Home Next
Embed Book Index eval()

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell

file: /Techref/language/java/script/definitive/refp_117.htm, 6KB, , updated: 2019/10/14 15:00, local time: 2024/11/12 22:46,
TOP NEW HELP FIND: 
18.222.107.27:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://techref.massmind.org/Techref/language/java/script/definitive/refp_117.htm"> [Chapter 21] Reference: escape()</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to techref.massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .