ASCII codes use a specified combination of 7-bit or 8-bit binary numbers to represent 128 or 256 possible characters. The standard ASCII code, also known as the base ASCII code, uses a 7-bit binary number (the remaining 1 bit binary is 0) to represent all uppercase and lowercase letters, numbers 0 through 9, punctuation, and special controls used in American English. character. among them:
0 to 31 and 127 (33 in total) are control characters or communication-specific characters (the rest are displayable characters), such as control characters: LF (line feed), CR (carriage return), FF (page change), DEL (delete) , BS (backspace), BEL (bell), etc.; communication-specific characters: SOH (header), EOT (end of text), ACK (acknowledgement), etc.; ASCII values ​​of 8, 9, 10, and 13 are converted to Grid, tabulation, line feed, and carriage return characters. They don't have a specific graphical display, but they have different effects on text display depending on the application.
32 to 126 (95 in total) are characters (32 is a space), of which 48 to 57 are 0 to 9 Arabic numerals.
65 to 90 are 26 uppercase English letters, 97 to 122 are 26 lowercase English letters, and the rest are some punctuation marks, arithmetic symbols, and so on.
Also note that in standard ASCII, its most significant bit (b7) is used as the parity bit. The so-called parity refers to the code used in the transmission process checks whether a method of error occurs, it normally two kinds of odd and even parity. Odd parity stipulates: the correct code must have an odd number of 1 in a byte. If it is not an odd number, add 1 to the highest bit b7; even parity specifies: the correct code must be an even number of 1 in a byte. If it is not even, add 1 to the highest bit b7.
The last 128 are called extended ASCII codes. Extended (or "high") ASCII is supported on many x86-based systems. Extended ASCII allows the 8th bit of each character to be used to determine the additional 128 special symbol characters, foreign letters, and graphic symbols.
ASCII is a computerized coding system based on the Latin alphabet, mainly used to display modern English and other Western European languages. It is the most versatile single-byte encoding system available today and is equivalent to the international standard ISO/IEC 646.
In the computer, all data is stored in binary numbers (because the computer uses high and low levels to represent 1 and 0, respectively), for example, 52 letters like a, b, c, d (including uppercase), and 0, 1 and other numbers and some commonly used symbols (such as *, #, @, etc.) should also be represented by binary numbers when stored in the computer, and which binary numbers are used to represent which symbols, of course Everyone can agree on their own set (this is called coding), and if you want to communicate with each other without causing confusion, then everyone must use the same coding rules, so the relevant American standardization organization has issued ASCII code. Uniformly stipulates which binary numbers are used to represent the above common symbols.
The American Standard Information Exchange Code is a standard single-byte character encoding scheme developed by the American National Standards Institute (ANSI) for text-based data. It began in the late 1950s and was finalized in 1967. It was originally a US national standard for Western computer character encoding standards used by different computers when communicating with each other. It has been designated as an international standard by the International Organization for Standardization (ISO) and is called the ISO 646 standard. Applies to all Latin alphabet letters.
ASCII and hexadecimal conversion c routine/ / Function name: AscToHex ()
/ / Function Description: Convert ASCII to hexadecimal
Unsigned char AscToHex(unsigned char hex)
{
If((hex _= 0) &&(hex <= 9))
Hex += 0x30;
Else if((hex _= 10) &&(hex <= 15)) //AF
Hex += 0x41;//0x37
Else
Hex = 0xff;
Return hex;
}
/ / Function name: HexToAsc ()
/ / Description of the function: convert hexadecimal to ASCII
Unsigned char HexToAsc(unsigned char aChar)
{
If((aChar》=0x30) &&(aChar“=0x39))
aChar -= 0x30;
Else if((aChar》=0x41) && (aChar“=0x46))//uppercase letters
aChar -= 0x41; //0x37
Else if((aChar"=0x61) && (aChar"=0x66))//lowercase letters
aChar -= 0x61; //0x57
Else
aChar = 0xff;
Return aChar;
}
Hexadecimal and ASCII code interchange (C language)/ / Function name: CharToHex ()
/ / Function Description: Convert ASCII characters to hexadecimal
/ / Function description:
//Call functions:
//Global variables:
/ / Input: ASCII characters
/ / Return: hexadecimal
[cpp] view plain copy/**function: CharToHex()
*** ACSII change to 16 hex
*** input:ACSII
***Return: Hex
**/
Unsigned char CharToHex(unsigned char bHex)
{
If((bHex》=0)&&(bHex“=9))
{
bHex += 0x30;
}
Else if((bHex"=10)&&(bHex"=15))//Capital
{
bHex += 0x37;
}
Else
{
bHex = 0xff;
}
Return bHex;
}
/ / Function name: HexToChar ()
/ / Function Description: Convert hexadecimal to ASCII characters
/ / Function Description: / / Call the function:
//Global variables:
/ / Input: hexadecimal
/ / Return: ASCII characters
[cpp] view plain copyunsigned char HexToChar(unsigned char bChar)
{
If((bChar》=0x30)&&(bChar“=0x39))
{
bChar -= 0x30;
}
Else if((bChar"=0x41)&&(bChar"=0x46)) // Capital
{
bChar -= 0x37;
}
Else if((bChar"=0x61)&&(bChar"=0x66)) //littlecase
{
bChar -= 0x57;
}
Else
{
bChar = 0xff;
}
Return bChar;
}
Scii code to hexadecimal principleEach ascii code corresponds to a fixed hexadecimal number. This value is constant and can be checked on the ascii code table.
The following is an ASCII and hexadecimal correspondence table:
Twinkle System Technology Co Ltd , https://www.pickingbylight.com