PHP详解ASCII码对照表与字符转换
一,通用的ASCII码对照表
图解ASCII码对照表图,以字符A为例
Dec表示十进制,如65
Hx表示十六进制,如41
Oct表示八进制,如101
Char表示显示字符,如A
ASCII码对照表图分为两个单元
1,控制字符 0-31和127
2,可显示字符 32-126
(1)48~57为0到9十个阿拉伯数字;
(2)65~90为26个大写英文字母;
(3)97~122号为26个小写英文字母;
(4)其它标点符号、运算符号等;
二,ASCII扩展码对照表
三,PHP字符转换函数说明
具体字符转换函数说明请参考[PHP函数篇详解十进制、二进制、八进制和十六进制转换函数说明]
十进制转二进制 decbin() 函数
十进制转八进制 decoct() 函数
十进制转十六进制 dechex() 函数
二进制转十六制进 bin2hex() 函数
二进制转十制进 bindec() 函数
八进制转十进制 octdec() 函数
十六进制转十进制 hexdec()函数
任意进制转换 base_convert() 函数
字符转换实例
实例一,如何把一个字符转换为二进制、八进制或十六进制,可以使用ord()函数先把字符转换为ASCII值,然后使用相应的进制转换函数进行转换,如下
a 这个字符转换为其二进制/八进制/十六进制,如下
a字符的十进制:ord('a'); //输出97
二进制:decbin(ord('a')); //输出1100001
八进制:decoct(ord('a')); //输出141
十六进制:dechex(ord('a')); //输出61
然后可以通过把各进制输出的结果对应上面ASCII码对照表图进行核对。
实例二,如何把一个二进制转换为十六进制或十进制,如a的二进制,如下
采用实例一的方法获取a字符的二进制
decbin(ord('a'));
然后把二进制转换为十六进制或十进制
十六进制:bin2hex(decbin(ord('a')));//输出31313030303031
二进制J:bindec(decbin(ord('a'))); //输出97
上面讨论的ord()函数,将在下一期中文字符编码研究系列中详细讨论。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



One ascii character occupies 1 byte. ASCII code characters are represented by 7-bit or 8-bit binary encoding in the computer and are stored in one byte, that is, one ASCII code occupies one byte. ASCII code can be divided into standard ASCII code and extended ASCII code. Standard ASCII code is also called basic ASCII code. It uses 7-bit binary numbers (the remaining 1 binary digit is 0) to represent all uppercase and lowercase letters, and the numbers 0 to 9. Punctuation marks, and special control characters used in American English.

ASCII value conversion in PHP is a problem often encountered in programming. ASCII (American Standard Code for Information Interchange) is a standard encoding system for converting characters into numbers. In PHP, we often need to convert between characters and numbers through ASCII code. This article will introduce how to convert ASCII values in PHP and give specific code examples. 1. Change the characters

This article will explain in detail the ASCII value of the first character of the string returned by PHP. The editor thinks it is very practical, so I share it with you as a reference. I hope you can gain something after reading this article. PHP returns the ASCII value of the first character of a string Introduction In PHP, getting the ASCII value of the first character of a string is a common operation that involves basic knowledge of string processing and character encoding. ASCII values are used to represent the numeric value of characters in computer systems and are critical for character comparison, data transmission and storage. The process of getting the ASCII value of the first character of a string involves the following steps: Get String: Determine the string for which you want to get the ASCII value. It can be a variable or a string constant

The differences between unicode and ascii include different encoding ranges, different storage spaces, and different compatibility. Detailed introduction: 1. The encoding range is different. The encoding range of ASCII is 0-127, which is mainly used to represent English letters. The encoding range of Unicode is much wider and can represent almost all language characters; 2. The storage space is different. ASCII usually Use 1 byte to store a character, while unicode may use 2 or more bytes to store a character; 3. Different compatibility, etc.

"How to accurately convert PHP strings to ASCII codes, specific code examples are needed" In the field of programming, ASCII (American Standard Code for Information Interchange) code is the standard encoding system used to represent characters in computer systems. In PHP, we often need to convert strings into ASCII codes for some operations or processing. Here's how to accurately convert a string to ASCII in PHP

In the PHP programming language, ASCII conversion is a very important skill. ASCII (American Standard Code for Information Interchange) is a character encoding that maps each character to a unique numeric value. In PHP, you may need to convert characters in a string to their corresponding ASCII values, or vice versa. In this article, we will explore how to do ASCII conversion in PHP,

Tips for converting characters to ASCII codes in PHP. In PHP development, sometimes we need to convert characters to ASCII codes. This is a very common operation in processing strings, encryption algorithms, etc. This article will share some techniques for converting characters to ASCII codes in PHP, and provide specific code examples to help everyone better understand and apply them. 1. Convert a single character to ASCII code First, let’s look at how to convert a single character to ASCII code. In PHP, you can use the ord() function to

Title: Let PHP easily complete the operation of converting characters to ASCII codes. In programming, we often encounter the operation of converting characters to ASCII codes. As a popular server-side scripting language, PHP also provides a simple and efficient way to achieve it. this conversion. This article will introduce how to use PHP to easily convert characters to ASCII code, as well as specific code examples. First, we need to understand the ASCII code (AmericanStandardCodeforInformati
