On-line Guides

How To Guides






The JavaScript FAQ
Prev Home Next

URL-encoding

Question: How do I convert a string to URL-encoding?

Answer: To convert a string to the URL-encoded form suitable for transmission as a query string (or, generally speaking, as part of a URL), use the escape function. This function works as follows: digits, Latin letters and the characters + - * / . _ @ remain unchanged; all other characters in the original string are replaced by escape-sequences %XX, where XX is the ASCII code of the original character. Example:

escape("It's me!") // result: It%27s%20me%21

In Unicode-aware browsers (that support JavaScript 1.3) the function escape has a more complex behavior. If the input is a Unicode string, then Unicode characters will be converted to the Unicode escape-sequences %uXXXX.

JavaScripter.net. Copyright © 1999-2006, Alexei Kourbatov

The JavaScript FAQ
Prev Home Next


Mirrored with kind permission of Alexei Kourbatov Design by Interspire

AltStyle によって変換されたページ (->オリジナル) /