Php ascii code comparison table and character conversion

Source: Internet
Author: User
Tags binary to decimal comparison table decimal to binary

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

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.