javascript in the escape, encodeURI the difference?

sponsored links

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: !*()'
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of javascript in the escape, encodeURI the difference?


    dsfdsa Tomcat 6 with the connection pool data source configuration project: test Driver path: D: \ workspace \ test \ WebRoot \ WEB-INF \ lib ...

  • Hibernate connection pool configuration

    Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @

  • hibernate generic generic DAO

    package org.lzpeng.dao; import; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

  • Servlet brief introduction

    Servlet brief introduction: Servlet is a small application server Are used to complete the B / S architecture, the client requests the response to treatment Platform independence, performance, able to run thread Servlet API for Servlet provides the s ...

  • can not be represented as java.sql.Timestamp

    Development of procedures for the use of hibernate when, some time there is no need to fill in the fields, but after the hibernate query time reported "Java.sql.SQLException: Value'0000-00-00 'can not be represented as java.sql.Timestamp ...

  • Spring2.0 + hibernate3.1 + log4j + mysql demo

    applicationContext.xml Non-attachment jar package, necessary friends can send an email to todd.liangt @

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

  • Hibernate secondary cache

    Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...

  • Hibernate's lazy strategy

    hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...

blog comments powered by Disqus
Recent Entries
Tag Cloud
Random Entries