One, common ASCII code comparison
illustration of an ASCII comparison chart , taking character A as an example
Dec means decimal, such as 65
HX represents hexadecimal, such as 41
Oct represents octal, such as 101
Char represents a display character, such as a
ASCII code comparison chart is divided into two units
1, control characters 0-31 and 127
2, can display the character 32-126
(1) 48~57 is 0 to 90 Arabic numerals;
(2) 65~90 is 26 uppercase letters;
(3) The 97~122 number is 26 lowercase English letters;
(4) Other punctuation marks, operation symbols, etc.;
Two, ASCII expansion code Comparison table
Three, PHP character conversion function description
Specific character conversion function description please refer to [PHP function chapter in decimal, Binary, octal and 16 conversion function description]
Decimal binary Decbin () function
Decimal spin octal decoct () function
Decimal hexadecimal Dechex () function
Binary turn 16 Bin2Hex () function
Binary Turn 10 Bindec () function
Octal decimal octdec () function
Hexadecimal decimal hexdec () function
Arbitrary-transform Base_convert () function
Character Conversion instances
instance one , how to convert a character to binary, octal, or hexadecimal, you can use the Ord () function to convert a character to an ASCII value, and then convert it using the corresponding feed conversion function, as follows
A this character is converted to binary/eight/16, as follows
The decimal of a character: Ord (' a '); Output 97
Binary: Decbin (Ord (' A ')); Output 1100001
Octal system: Decoct (Ord (' A ')); Output 141
Hex: Dechex (Ord (' A ')); Output 61
It can then be checked by the output of each input corresponding to the above ASCII code comparison chart.
example two , how to convert a binary to a binary of 16 or a decimal, such as a binary, as follows
Using instance one to get binary of a character
Decbin (Ord (' A '));
Then convert the binary to 16 or decimal
Hex: Bin2Hex (Decbin (Ord (' A '));//Output 31313030303031
Binary J:bindec (ord (' A ')) (Decbin); Output 97
The Ord () function discussed above is discussed in detail in the next issue of the text Encoding Research series.
Iv.. Reference materials
PHP functions in decimal, binary, octal and 16 conversion function description
Asciitable Comparison Chart
Wikipedia ASCII
Baidu Encyclopedia ASCII