Escape, encodeuri, and encodeuricomponent in Javascript

Source: Internet
Author: User
Method Non-encoded ASCII characters
Same character Different Characters Total
Escape () 0-9
A-z
A-Z
*._-
@ +/ 69
Encodeuri () ! ()'~ ,:; # $ @/&? + = 82
Encodeuricomponent () ! ()'~ 71

Character ASCII
(Hexadecimal)
Unicode
(Hexadecimal)
Unicode
(Binary)
UTF-8 Storage
(Hexadecimal)
UTF-8 byte stream
(Binary)
Escape Encodeuri Encodeuricomponent
A 41 41 00000000 01000001 41 01000001 A A A
Z 5A 5A 00000000 01011010 5A 01011010 Z Z Z
A 61 61 00000000 01100001 61 01100001 A A A
Z 7A 7A 00000000 01111010 7A 01111010 Z Z Z
0 30 30 00000000 00110000 30 00110000 0 0 0
9 39 39 00000000 00111001 39 00111001 9 9 9
I - 4e 00 01001110 00000000 E4 B8 80 11100100 10111000 10000000 % U4e00 % E4 % B8 % 80 % E4 % B8 % 80
Bytes - 9f A5 10011111 10100101 E9 be A5 11101001 10111110 10100101 % U9fa5 % E9 % be % A5 % E9 % be % A5

Joy is in the air!


Test code:

Run code

VaR S = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789 *. _-"; document. writeln ("<br/> Test 1. unencoded characters-ASCII letters and numbers and *. _-"); document. writeln ("<HR/>"); document. writeln ("escape (\" "+ S +" \ "):" + escape (s) + "<br/>"); document. writeln ("encodeuri (\" "+ S +" \ "):" + encodeuri (s) + "<br/>"); document. writeln ("encodeuricomponent (\" "+ S +" \ "):" + encodeuricomponent (s) + "<br/>"); D Ocument. writeln ("<br/> Test 2. unencoded character -- special symbol "); document. writeln ("<HR/>"); document. writeln ("escape (\" *-+ @_. /\ "):" + escape ("* @-_ +. /") +" <br/> "); document. writeln ("encodeuri (\"! *()'~ _.,:; # $ @/&? +-= \ "):" + Encodeuri ("! *()'~ -_.,:; # $ @/&? + = ") +" <Br/> "); document. writeln (" encodeuricomponent (\"! *()'~ -_. \ "):" + Encodeuricomponent ("! *()'~ -_. ") +" <Br/> "); document. writeln ("<br/> Test 3. the encoded character -- special symbol "); document. writeln ("<HR/>"); document. writeln ("escape (\"?! = () # % & $,:; '[] {}\\' \ "):" + Escape ("?! = () # % & $,:; '[] {}\\' ") +" <Br/> "); document. writeln ("encodeuri (\" [] {}\\ "% '\"): "+ encodeuri (" [] {}\\ "% '") + "<br/>"); document. writeln ("encodeuricomponent @/&? + = [] {}\\ "% '\"): "+ Encodeuricomponent (" ,:;#$ @/&? + = [] {}\\ "% '") + "<Br/>"); document. writeln ("escape (\" ran \ "):" + escape ("ran") + "<br/>"); document. writeln ("encodeuri (\" ran \ "):" + encodeuri ("ran") + "<br/>"); document. writeln ("encodeuricomponent (\" ran \ "):" + encodeuricomponent ("ran") + "<br/> ");

Run code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.