Php ascii code comparison table and character conversion

Source: Internet
Author: User
Tags binary to decimal decimal to binary
PHP detailed ASCII code comparison table and character conversion. 1. general ASCII code table schematic ASCII code table chart. take character A as an example to describe decimal. for example, 65Hx indicates Hexadecimal. for example, 41Oct indicates octal, for example, 101Char indicates display. 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 () 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
Php batch ascii conversion string
Asciitable table chart
Wikipedia ASCII
Baidu Encyclopedia ASCII

The preceding section describes the ASCII code table and character conversion in PHP. For more information, see PHP Chinese website (www.php1.cn )!

The ASCII code comparison table in the "numeric" diagram. take character A as an example to describe the decimal number. for example, 65 Hx indicates the hexadecimal format. for example, 41 Oct indicates the octal format. for example, 101 Char indicates the display word...

Related Article

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.