Will the C compiler actually have an ascii lookup table

I know that there are several similar issues related to this, but this is still not entirely clear.

For example: if I have many specific string literals in my C source file, since the compiler translates this source file, it looks at each character of the strings and uses the lookup table to get the ascii number for each character?

I would suggest that if you dynamically enter characters into a running C program from standard input, this is a terminal that translates real characters into numbers, but then if we have in the code, for example:

if (ch == 'c'){//.. do something}

should the compiler have its own way of understanding and matching characters with numbers?

Thanks in advance for your help in my confusion.

+4
source share
3 answers

The C standard refers to the source character set, which is the character set that it expects to find in the source files, and the run character set, which is the character set used initially by the target platform.

For most modern computers that you are likely to encounter, the source and executive character sets will be the same.

The type string if (ch == 'c')will be saved in the source file as a sequence of values ​​from the source character set. For the part, the 'c'representation is most likely 0x27 0x63 0x27where they 0x27represent single quotation marks, but 0x63represent a letter c.

, 0x63 . .

, , (, , - IBM, EBCDIC), , 0x63 c, .


, , . , ( ), , .

" ASCII" : A c 0x63 0x63.

ASCII, . , Unicode, UTF-8, UTF-16 UTF-32, Unicode ( ) .

, , / , , , , .

Unicode ( Unicode). Unix- UTF-8. Windows UTF-8 UTF-16, , .

Unicode, (, ) ASCII .


, (, ), : (1) , (2) (3) .

unix UTF-8, UTF-8 .

Windows Unicode (BOM), UTF-16 UTF-8. , (IsTextUnicode), , , .

, ASCII, . UTF-8 ASCII. (, ASCII UTF-8.) ASCII, ASCII . UTF-16 UTF-32 ASCII, , , .

. - . - (, , ), , .

+4

. , ASCII, , .

, int 'c' , , , . ASCII - , , C , , '0' '9' , , char. , 'A' to 'Z' 'a' to 'z' , char.

+1

, ​​. pre-C11, EBCDIC EBCDIC. ASCII ?

Also think again about what such ASCII lookup tables look like in such a compiler!

0
source

Source: https://habr.com/ru/post/1694789/


All Articles