URL encoding (URL encoding)

Source: Internet
Author: User
Tags urlencode

URL encoding (URL encoding), also known as percent-encoding (percent-encoding), refers to the Uniform Resource Locator (URL) encoding mechanism for a specific context
UrlEncode: Encodes a string as a URL
return value: String
Function type: Encoding processing
Coding principle:
Convert the required characters into 16, then from right to left, take 4 bits (less than 4 direct processing), each 2 bits to do a bit, preceded by%, encoded into%XY format.
The essence of URL encode is the correct use of percent encode (percent-semicolon encoding)
For example: The ASCII code is-10544, the corresponding 16 binary is ffffffffffffd6d0, then the UrlEncode encoding result is:%d6%d0
Current Coding principle:
At the beginning of the WWW, the practice is to convert the character stream into byte streams, in accordance with the ASCII characters corresponding to bytes one by one can be converted to each other, using the corresponding ASCII character integer value as a% of the latter two 16 characters, constitute percent encoding. A number of percent encoding generation methods have emerged, resulting in the difficulty of identifying URIs.
The current practice, the designation or system default to use UTF8 into a stream of bytes, each byte into a percent encoding, for example: Chinese "netease" URL Code of%e7%bd%91%e6%98%93, and its UTF8 byte stream E7 bd e6 93, you can see its one by one correspondence

principles:In the constituent characters of the URI, the safest scheme is to use the set of "reserved character" and "non-reserved character" correctly.
Reserved characters: Characters that function in the URL, such as &,?. So the URL rules are "reserved".
reserved Words (Reserved):! * ‘ () ; : @ & = + $,/? # []
non-reserved Words (unreserved): 0 to 9 of the number-_. ~ A to Z A to Z

Follow the principles:
1 Do not unreserved (non-reserved words) do percent encode (percent code)
2 all characters except reserved and non-reserved words must be percent encode (percent-semicolon encoded)
3 when the reserved character is not used for the URL delimiter, but for other locations, such as the value after query, to do the reserved word used to do percent encode (percent code)

URL encoding (URL encoding)

Related Article

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.