Home > Common Problem > body text

How to understand coding

coldplay.xixi
Release: 2020-10-26 15:30:42
Original
6047 people have browsed it

How to understand encoding: 1. Base64 is one of the most common encoding methods used to transmit 8Bit bytecode on the Internet. Base64 is a method of representing binary data based on 64 printable characters; 2. [UTF-8] is a variable-length character encoding for Unicode, also known as Unicode.

How to understand coding

How to understand coding:

Coding is mainly divided into two parts

Base64 is one of the most common encoding methods for transmitting 8Bit bytecode on the Internet. Base64 is a method of representing binary data based on 64 printable characters.

UTF-8 (8-bit Unicode Transformation Format) is a variable-length character encoding for Unicode, also known as Unicode. Created by Ken Thompson in 1992. It is now standardized as RFC 3629. UTF-8 encodes Unicode characters using 1 to 6 bytes. Used on web pages, the page can display simplified, traditional, and other languages ​​(such as English, Japanese, Korean) in a unified manner.

utf-8 is an encoding method of unicode (the character "I" after unicode encoding is \u6211 \u represents Chinese, 6211 is the binary data of this character in the comparison table displayed in hexadecimal) , is the expression of characters, such as what kind of binary represents what kind of characters, there is a comparison table, base64 is a binary encoding that facilitates transmission. For example, when transmitting a picture, you can encode the binary base64 of the picture and pass it through parameters. For other recipients, it is not the same concept.

UrlEncode Convert the characters that need to be transcoded into hexadecimal, and then take 4 digits from right to left (less than 4 digits will be processed directly), and do one for every 2 digits. Bit, preceded by %, is encoded in %XY format. (This also involves what kind of encoding method to use, generally utf-8. The encoding method determines what kind of binary it is converted into, and then it is converted into hexadecimal through urlencode, and % is added according to the rules) The encoded result is more suitable for network transmission. Same as base64, but base64 is only responsible for binary encoding

urlencode encoding/urldecode decoding

Convert the characters that need to be transcoded into hexadecimal (using UTF-8 Or unicode encoding comparison table such as gb2312), then take 4 digits from right to left (less than 4 digits are processed directly), make one digit for every 2 digits, add % in front, and encode it into %XY format.

For example: the ASCII code of a space is 32, and the corresponding hexadecimal value is 20, then the urlencode encoding result is: , but in the new standard, the corresponding space is, see RFC-1738

For example: The ASCII code is -10544, and the corresponding hexadecimal is FFFFFFFFFFFFD6D0. Then the urlencode encoding result is: ��

What encoding does the browser use? When the server returns, tell the browser what encoding to use (response.setContentType( "text/html;charset=UTF-8");), when the browser makes a request, it will also encode the content of this request, such as Chinese, according to the encoding method returned last time

If you want to learn more about programming, please pay attention to the php training column!

The above is the detailed content of How to understand coding. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template