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 = "http://passport.baidu.com/?logout&aid=7&u = + encodeURIComponent (" http://cang.baidu.com/bruce42 withdraw from the ")+"> </ a >');</ script>

2, Jump to url when the overall use of encodeURI

For example: Location.href = encodeURI ( "http://cang.baidu.com/do/s?word = 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 人气:1727
分享到:
blog comments powered by Disqus

相关文章

  • Completely resolved with the UTF-8 JSP + MYSQL multi-language text encoding issues 2010-05-13

    http://blog.csdn.net/shangpusp/archive/2009/04/06/4052943.aspx Completely resolved with the UTF-8 JSP + MYSQL multi-language text encoding issues Reprinted Source: http://blog.donews.com/ralix/ First, a couple of points: Occur at any time in the file

  • In java, you will utf-8 character code mapped into the Chinese 2010-03-29

    The following is a character code conversion tool. In this leave a mark can only be run under jdk1.6. utf16 this class jre / lib / rt.jar under. /* * (#)CharsetConvertor.java 1.0 2009-8-19 */ package com.codelib.util; import java.io.UnsupportedEncodi

  • 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

  • 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

  • Chinese javascript AJAX Problem summary 2009-03-15

    Ajax garbled today met the problem, at-line for a long time to find information on a variety of test methods, and finally found this article or tell me the correct way, and would like to thank. Original Address: http://www.blogjava.net/hulizhong/arch

  • Collection of static pages generated website cms [reproduced] 2010-06-14

    Wind News site content management system (FoosunCMS) Official Website http://www.foosun.net/ Official Forum http://bbs.foosun.net/ The latest and updated V4.0 sp4 20070412 Download http://www.foosun.net/FsDown/DownLoad/ CMS products in the field, Foo

  • js operation frame for news tips 2010-09-22

    As title index.html top.html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <

  • The first Javacript program 2010-10-06

    <! - To change this template, choose Tools | Templates and open the template in the editor. -> <! DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN"> <html> <head> <title> first javascript program

  • JavaScript Arithmetic Operators 2010-10-06

    <! - To change this template, choose Tools | Templates and open the template in the editor. -> <! DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN"> <html> <head> <title> using maths </ title&

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

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