Application of ASCII code table

1. What is the ASCII code table

ASCII codes use specified combinations of 7- or 8-bit binary numbers to represent 128 or 256 possible characters. The standard ASCII code is also called the basic ASCII code. It uses 7-bit binary numbers to represent all uppercase and lowercase letters, numbers 0 to 9, punctuation marks, and special control characters used in American English. Here is a very detailed description of ASCI . introduction .

2. Why do we have an ASCII code table

Our computer can only store binary data and cannot store these characters. However, our language needs these characters, so how does our program process characters? There must be a rule here, use a value of [0, 127] to represent a character (English letter, symbol, etc.), so that there is a one-to-one correspondence, then this is our ASCII code table.

3. ASCII code table application

For example, our ASCII code A corresponds to a value of 65, so in the memory, is there any difference between 'A' and 65? The answer is that there is no difference at all, that is, the binary of 65 is stored. When you treat 65 as data, then it is 65; if you treat it as a character, then our computer will call the programming of computer graphics to draw our A's graphics on the screen, then the ratio is Can see A, give a code example:

 int a = 'a';
 int b = a + 1;
 int c = 52;

 // %c表示输出互相转换对应的ASCII值
 NSLog(@"%d   %c  %c",a,b,c);

Look at the console output:

Write picture description here

We see that 'a' is 97 when you want to output integer, and 98 when you want to output characters, it is b.

Guess you like

Origin blog.csdn.net/SSY_1992/article/details/79119979