Every % XX after urlencode represents one byte?

Source: Internet
Author: User
After the Chinese urlencode, each % XX represents a byte, right? Therefore, the result of urlencode (& #039; & #039;) is % XX (UTF-8 encoded). each % XX represents one byte, is that true?
Therefore, the urlencode (in ') is % XX (UTF-8 encoding)

Reply content:

After the Chinese urlencode, each % XX represents a byte, right?
Therefore, the urlencode (in ') is % XX (UTF-8 encoding)

Yes. in order to solve the problem that unicode occupies too much memory space and expansion remains unchanged, the UTF-8 specification emerged.

  1. For a single-byte symbol, the first byte is set to 0, and the last seven digits are the unicode code of this symbol. Therefore, for English letters, the UTF-8 encoding and ASCII code are the same.

  2. For the n-byte symbol (n> 1), the first n bits of the first byte are set to 1, and the nth + 1 bits are set to 0, the first two bytes are set to 10. The remaining unmentioned binary bits are all unicode codes of this symbol.

That is to say, the UTF-8 encoding result is longer.
MediumUTF-8 encoding isE4B8AD, So the urlencode is%E4%B8%AD.

Yes, the URL encoding simply represents the data of special characters and non-ASCII characters in hexadecimal notation, and adds a percent sign before each byte (that is, two hexadecimal numbers. URL encoding for non-special ASCII characters is itself.

In the same word, if it is GBK encoding is two bytes, if it is UTF-8 is three bytes.

Of course, the trouble is that the URL encoding is chaotic. For example+To indicate spaces.%20To analyze the specific situation. The former corresponds to the functionurlencodeWhich correspondsrawurlencode. Usually, the former is used in form data (including the query in the URL, that is?The latter part is used in the URL path (the part before the host query)

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.