escape,encodeURI,encodeURIComponent, URLEncode, RawURLEncode, HTMLEntity, AddSlash, JSON Encode

online tooling: http://www.the-art-of-web.com/javascript/escape/

input : {user:{id:59,innerhtml:"<div>content of inner html</div>"}, data: [1,2,5]}

1. JSON ENCODE:  "{user:{id:59,innerhtml:\"<div>content of inner html<\/div>\"}, data: [1,2,5]}"

2. escape:

%7Buser%3A%7Bid%3A59%2Cinnerhtml%3A%22%3Cdiv%3Econtent%20of%20inner%20html%3C/div%3E%22%7D%2C%20data%3A%20%5B1%2C2%2C5%5D%7D

3. encodeURI:

%7Buser:%7Bid:59,innerhtml:%22%3Cdiv%3Econtent%20of%20inner%20html%3C/div%3E%22%7D,%20data:%20%5B1,2,5%5D%7D

4. EncodeURIComponent:

%7Buser%3A%7Bid%3A59%2Cinnerhtml%3A%22%3Cdiv%3Econtent%20of%20inner%20html%3C%2Fdiv%3E%22%7D%2C%20data%3A%20%5B1%2C2%2C5%5D%7D

5. URL Encode: PHP function:urlencode

%7Buser%3A%7Bid%3A59%2Cinnerhtml%3A%22%3Cdiv%3Econtent+of+inner+html%3C%2Fdiv%3E%22%7D%2C+data%3A+%5B1%2C2%2C5%5D%7D

6. Raw URL Encode: PHP function:rawurlencode

%7Buser%3A%7Bid%3A59%2Cinnerhtml%3A%22%3Cdiv%3Econtent%20of%20inner%20html%3C%2Fdiv%3E%22%7D%2C%20data%3A%20%5B1%2C2%2C5%5D%7D

7. HTML Entities: PHP function:htmlentities

{user:{id:59,innerhtml:&quot;&lt;div&gt;content of inner html&lt;/div&gt;&quot;}, data: [1,2,5]}

8. Add Slashes: PHP function:addslashes

{user:{id:59,innerhtml:\"<div>content of inner html</div>\"}, data: [1,2,5]}

9.  UTF8 Encode: PHP function:utf8_encode

{user:{id:59,innerhtml:"<div>content of inner html</div>"}, data: [1,2,5]}

10. JSON.stringify()

"{"user":{"id":59,"innerhtml":"<div>content of inner html</div>"},"data":[1,2,5]}"

input: "{"user":{"id":59,"innerhtml":"<div>content of inner html</div>"},"data":[1,2,5]}"

escape:

%22%7B%22user%22%3A%7B%22id%22%3A59%2C%22innerhtml%22%3A%22%3Cdiv%3Econtent%20of%20inner%20html%3C/div%3E%22%7D%2C%22data%22%3A%5B1%2C2%2C5%5D%7D%22

encodeURI:

%22%7B%22user%22:%7B%22id%22:59,%22innerhtml%22:%22%3Cdiv%3Econtent%20of%20inner%20html%3C/div%3E%22%7D,%22data%22:%5B1,2,5%5D%7D%22

encodeURIComponent:

%22%7B%22user%22%3A%7B%22id%22%3A59%2C%22innerhtml%22%3A%22%3Cdiv%3Econtent%20of%20inner%20html%3C%2Fdiv%3E%22%7D%2C%22data%22%3A%5B1%2C2%2C5%5D%7D%22

URLEncode:

%22%7B%22user%22%3A%7B%22id%22%3A59%2C%22innerhtml%22%3A%22%3Cdiv%3Econtent+of+inner+html%3C%2Fdiv%3E%22%7D%2C%22data%22%3A%5B1%2C2%2C5%5D%7D%22

Raw URL Encode:

%22%7B%22user%22%3A%7B%22id%22%3A59%2C%22innerhtml%22%3A%22%3Cdiv%3Econtent%20of%20inner%20html%3C%2Fdiv%3E%22%7D%2C%22data%22%3A%5B1%2C2%2C5%5D%7D%22

HTML Entities:

&quot;{&quot;user&quot;:{&quot;id&quot;:59,&quot;innerhtml&quot;:&quot;&lt;div&gt;content of inner html&lt;/div&gt;&quot;},&quot;data&quot;:[1,2,5]}&quot;

AddSlashes:

\"{\"user\":{\"id\":59,\"innerhtml\":\"<div>content of inner html</div>\"},\"data\":[1,2,5]}\"

JSON Encode:

"\"{\"user\":{\"id\":59,\"innerhtml\":\"<div>content of inner html<\/div>\"},\"data\":[1,2,5]}\""

时间: 2024-10-12 08:58:54

escape,encodeURI,encodeURIComponent, URLEncode, RawURLEncode, HTMLEntity, AddSlash, JSON Encode的相关文章

url的三个js编码函数escape(),encodeURI(),encodeURIComponent()简介

url的三个js编码函数escape(),encodeURI(),encodeURIComponent()简介 2014年10月12日 16806次浏览 引子 浏览器URl地址,上网一定会用到,但是浏览器地址有中文或者浏览器url参数操作的时候,经常会用到encodeURIComponent()和decodeURIComponent()以及encodeURI()等等.关于浏览器参数操作,请看文章http://www.haorooms.com/post/js_url_canshu ,今天主要讲讲e

url的三个js编码函数escape(),encodeURI(),encodeURIComponent()简介【转】

引子 浏览器URl地址,上网一定会用到,但是浏览器地址有中文或者浏览器url参数操作的时候,经常会用到encodeURIComponent()和decodeURIComponent()以及encodeURI()等等.关于浏览器参数操作,请看文章http://www.haorooms.com/post/js_url_canshu ,今天主要讲讲escape(),encodeURI(),encodeURIComponent()这几个函数的用法和区别. 为啥会有浏览器编码这一说法 一般来说,URL只能

JavaScript中有对字符串编码的三个函数:escape,encodeURI,encodeURIComponent

JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decodeURIComponent . 下面简单介绍一下它们的区别 1 escape()函数 定义和用法 escape() 函数可对字符串进行编码,这样就可以在所有的计算机上读取该字符串. 语法 escape(string) 参数  描述  string  必需.要被转义或编码的字符串. 返回值 已编码的

JavaScript中有三个可以对字符串编码的函数,分别是: escape(),encodeURI(),encodeURIComponent()

JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decodeURIComponent . 下面简单介绍一下它们的区别 1 escape()函数 定义和用法 escape() 函数可对字符串进行编码,这样就可以在所有的计算机上读取该字符串. 语法 escape(string) 参数  描述  string  必需.要被转义或编码的字符串. 返回值 已编码的

escape,encodeURI,encodeURIComponent

JavaScript/js中,有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decodeURIComponent . escape()函数 定义和用法 :escape() 函数可对字符串进行编码,这样就可以在所有的计算机上读取该字符串. 语法 :escape(string) 参数  描述  :string  必需.要被转义或编码的字符串. 返回值 :已编码的 string 的

escape, encodeURI, encodeURIComponent 的使用情况

escape, encodeURI, encodeURIComponent 的使用情况: 1.js使用数据时可以使用escape: 2.传递参数时需要使用encodeURIComponent,这样组合的url才不会被#等特殊字符截断: 3.进行url跳转时可以整体使用encodeURI.例如: Location.href = encodeURI(“http://www.javaweb.cc”): 4.escape对0-255以外的unicode值进行编码时输出%u****格式,其它情况下esca

js escape, encodeURI, encodeURIComponent

escape,   encodeURI,   encodeURIComponent 1)基本介绍 js 对文字进行编码涉及3个函数:escape,encodeURI,encodeURIComponent, 相应3个解码函数:decodeURI,decodeURIComponent 2)用途 1.   传递参数时需要使用encodeURIComponent,这样组合的url才不会被#等特殊字符截断. 例如:"http://www.baidu.com?name="+encodeURICom

escape encodeuri encodeuricomponent区别

escape不编码字符有69个:*,+,-,.,/,@,_,0-9,a-z,A-Z encodeURI不编码字符有82个:!,#,$,&,',(,),*,+,,,-,.,/,:,;,=,?,@,_,~,0-9,a-z,A-Z encodeURIComponent不编码字符有71个:!, ',(,),*,-,.,_,~,0-9,a-z,A-Z Form表单提交,比如新闻内容作为POST的参数提交,推荐escape编码 相关: AntiXssEncoder 类(https://msdn.micros

escape,encodeURI,encodeURIComponent的区别

escape是对字符串进行编码而另外两种是对URL. encodeURI方法不会对下列字符编码 ASCII字母 数字 [email protected]#$&*()=:/,;?+'encodeURIComponent方法不会对下列字符编码 ASCII字母 数字 ~!*()' encodeURIComponent比encodeURI编码的范围更大. 1.编码字符串,用escape(). 2.编码url,且该url需要使用,用encodeURI,http://,encodeURIComponent(