首页 > 代码库 > escape,encodeURI,encodeURIComponent, URLEncode, RawURLEncode, HTMLEntity, AddSlash, JSON Encode
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:"<div>content of inner html</div>"}, 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:
"{"user":{"id":59,"innerhtml":"<div>content of inner html</div>"},"data":[1,2,5]}"
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]}\""
escape,encodeURI,encodeURIComponent, URLEncode, RawURLEncode, HTMLEntity, AddSlash, JSON Encode