javascript in the escape, encodeURI the difference?

javascript in the escape, encodeURI the difference?

javascript in the escape, encodeURI the difference?

js code to the text involves three functions: escape, encodeURI, encodeURIComponent, the corresponding three decoding function: unescape, decodeURI, decodeURIComponent

1, transmission parameters need to use encodeURIComponent, this portfolio would not be # url special characters, such as cut-off.

For example: <script language="javascript"> document.write ( '<a href = " = + encodeURIComponent (" withdraw from the ")+"> </ a >');</ script>

2, Jump to url when the overall use of encodeURI

For example: Location.href = encodeURI ( " = Baidu & ct = 21");

3, js the use of data can be used escape

For example: a record collector in history.

4, escape to the outside 0-255 encode unicode output value% u **** format, other cases escape, encodeURI, encodeURIComponent encoding the same result.

Should be used up to encodeURIComponent, it is Chinese, Korean and other special characters into utf-8 encoding format of the url, so if the need to pass parameters to the background needed to use the background encodeURIComponent decoding utf-8 support on the (form of coding coding methods and the same manner as the current page)

escape character is not coded 69 :*,+,-,.,/,@,_, 0-9, az, AZ

encodeURI do not have a 82 character code :!,#,$,&,',(,),*,+,,,-,.,/,:,;,=,?,@,_,~, 0 -- 9, az, AZ

encodeURIComponent not encode 71 characters:!,',(,),*,-,.,_,~, 0-9, az, AZ

================================================== =====================

escape () method:
All spaces, punctuation, accented characters, as well as any other non-ASCII characters are replaced by code "% XX" format, xx is the number represented by 16 hexadecimal.
escape and unescape functions of encoding and decoding, escape back to a 16-band encoding ISO Latin character sets. unescape function is of special value to the 16-band coding is converted to ASCII string, for example:
escape ('!@#$%^&*(){}[]=:/;?+ \'"'):
The results:% 21 @% 23% 24% 25% 5E% 26 *% 28% 29% 7B% 7D% 5B% 5D% 3D% 3A /% 3B% 3F +% 27% 22

encodeURI () method returns an Encodeuri encoded URI. Therefore, if you will use the results Decodeuri method will return the original string. Encodeuri approach will not be on the following character encoding :":","/","; " , "?." encodeuricomponent but the method can be used for these characters encode.
encodes, a Uniform Resource Identifier (URI) (URI) to replace some of the characters one by one, described as UTF-8 encoded character.
For example:
encodeURI ('!@#$%^&*(){}[]=:/;?+ \'"'):
The results :!@#$% 25% 5E &*()% 7B% 7D% 5B% 5D =:/;?+'% 22

encodeURIComponent () method:
encodeuricomponent method returns an encoded URI. Therefore, if you will decodeuricomponent, will return the original string. encodesencodeuricomponent because of all the text encoding methods, so be careful, if there is the path string, such as for example: "/ FOLDER1/FOLDER2/DEFAULT.HTML . "encrypted and will not, as a network server if the request will lapse. Encodeuri use this method when the string composed of more than one URI.
encodes, a Uniform Resource Identifier (URI) (URI) to replace some of the characters one by one, described as UTF-8 encoded character.
Example: The simplest way is to see these characters after they are encrypted to generate the code.
encodeURIComponent ('!@#$%^&*(){}[]=:/;?+ \'"'):
Results!% 40% 23% 24% 25% 5E% 26 * ()% 7B% 7D% 5B% 5D% 3D% 3A% 2F% 3B% 3F% 2B '% 22

-------------------------------------------------- ------------------------------

When the method used for?

escape () method does not encrypt + the server side will be resolved to form a space as well as forms of regional spaces. based on the reduction of the way as much as possible you should avoid using this method, a second election, it is most frequent use of good encodeURIComponent ().

escape () will not be encrypted: @ * / +

The use of encodeURI () than the escape () is slightly specialized, it is encoded URIs. Querystring as a negative one, is a part of URL. Use this method when you need to convert a string resource ID, as well as URIs some characters need to maintain a state of non-encode. Please keep in mind that the 'character is not encoded, because it itself is included in the URIs in.

encodeURI () will not be encrypted: !@#$&*()=:/;?+'

Finally, encodeURIComponent () method used in most cases, when you need parts for a single encoded URIs, this method can be used for encryption of certain special characters in URIs, most components can be included inside. Remember , 'character itself included in the URIs in, so this method will not be encoded.

encodeURIComponent () will not be encrypted: !*()'

分类:AJAX 时间:2009-10-12 人气:1749
blog comments powered by Disqus


  • C language arrays and structure parameters 2010-05-24

    Array Array Structure Struct Learning C language, basic types (Primitive Type) have read almost to the array and structure of the body to. As the C language, the most basic of the most common type of composite (Compound Type), when passed as an argum

  • C language character constants and string notes 7 2010-07-23

    From a technical point of view, a string constant is an array of characters. Internal representation of strings uses a null character '\ 0' as the end of the string. Therefore, the physical memory cells store a string enclosed in double quotation mar

  • How in the C language to implement variable-length parameters 2010-11-30

    As we all know, C language printf realized that the parameters of variable length, in fact, C language standard library already provides an interface for our use, by the realization that we can be very simple parameters of variable-length argument. B

  • C language character constants in a string constant What is the difference 2010-04-20

    Single quotation marks in a character to character constants, such as: 'A' Character constants can be stored in a character variable, as seen in: char ch = 'a'; Double quotes in a string of characters in a string constant, such as: "A", "AB

  • Latex 中文简历 过程(更新Miktex和 修改utf字体) 2014-07-09 问题部分,因为转成的图片太麻烦了,所以直接给出上面的连接. 这也是我喜欢evernote 的一个原因,所有图片都可以直接复制粘贴. Latex 中文简历 1. 开始下载了别人的模板(

  • js collection form to verify 2009-05-13

    Keyword: js form validation Book, using JS to control form submission, javascript submit form: Contents: 1: js string length to determine the length of characters, js restrict the importation, should not restrict the importation, textarea length limi

  • Common JavaScript object (1) 2008-09-25

    <Script language="javascript"> var s = " I have a 7 characters "; var str = " Characters " + " Series "; // Use the string of the length property to a string of length . alert(s.length); // Use the charAt meth

  • Character encoding Study Notes 2010-02-25

    unicode: also known as Unicode is an industry standard computer field, it is based on the universal character set. Unicode function is to provide each character a unique code (ie a set of figures), rather than a shape and the visual interpretation of

  • JavaScript pop-up window 2010-03-27

    A common pop-up window <br /> use the following code uses a collection of popular pop-up windows. 1, the basic pop-up window code <SCRIPT LANGUAGE="javascript"> <! - ('page.html') -> </ SCRIPT> <SCRIPT LANG

  • Code Complete, js form validation control 2010-04-02 Keywords: js form validation Daquan, control with JS form submission, javascript submit form: Contents: 1: js string length, determine the length of characters, js import restrictions, lim

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 黔ICP备15002463号-1

processed in 0.109 (s). 12 q(s)