I. general ASCII code table
Schematic ASCII code comparison tableTake character A as an example.
Dec indicates decimal, such as 65
Hx indicates hexadecimal, such as 41
Oct indicates octal, for example, 101
Char indicates the display character, such as
The ASCII code table is divided into two units.
1. control characters 0-31 and 127
2, can display characters 32-126
(1) 48 ~ 57 is 0 to 9 10 Arabic numerals;
(2) 65 ~ 90 is 26 uppercase English letters;
(3) 97 ~ 26 lowercase English letters (122;
(4) other punctuation marks and operator numbers;
Ii. ASCII extended code table
Iii. PHP character Conversion Function Description
For details about specific character conversion functions, refer to [instructions on decimal, binary, octal, and hexadecimal conversion functions for PHP functions]
Decimal to binary decbin () function
Decimal to octal decoct () function
Decimal to hexadecimal dechex () function
Binary to hexadecimal bin2hex () function
Binary to decimal to bindec () function
Octal to decimal dec Dec () function
Hexadecimal to decimal hexdec () function
Any hexadecimal conversion base_convert () function
Character conversion instance
Instance 1To convert a character to binary, octal, or hexadecimal, you can use the ord () function to convert the character to ASCII value first, and then use the corresponding hexadecimal conversion function for conversion, as follows:
The character a is converted to its binary/octal/hexadecimal format, as follows:
A character in decimal format: ord ('A'); // output 97
Binary: decbin (ord ('A'); // output 1100001
Octal score: decoct (ord ('A'); // output 141
Hexadecimal: dechex (ord ('A'); // output 61
Then, you can verify the results of each hexadecimal output corresponding to the above ASCII code comparison table.
Instance 2, How to convert a binary to hexadecimal or decimal, such as the binary of a, as follows:
Use instance 1 to obtain the binary string of the character
Decbin (ord ('A '));
Convert binary to hexadecimal or decimal
Hexadecimal: bin2hex (decbin (ord ('A'); // output 31313030303031
Binary J: bindec (decbin (ord ('A'); // output 97
The ord () function discussed above will be discussed in detail in the next series of Chinese character encoding studies.
Iv. References
PHP function description: decimal, binary, octal, and hexadecimal conversion functions
Asciitable table chart
Wikipedia ASCII
Baidu encyclopedia ASCII