Forgive me for the stupid question. But I was wondering what character set C's char type uses. At first I thought it was ASCII, but then I realized it could reach 255 which exceeds ASCII's 127 characters. What character set is this? Extended ASCII?
CodePudding user response:
The C standard does not require C implementations to use a particular character set. It requires the execution character set (used in running programs, in contrast to the source character set used when compiling) to have the Latin alphabet letters A-Z and a-z, the digits 0-9, these characters:
!"#%&’()* ,-./:;?[\]^_{|}~
the space character, and characters for horizontal tab, vertical tab, form feed, alert, backspace, carriage return, and new line. It requires the codes for the digits to be consecutive from the code for 0 to the code for 9, and the character value zero must be available to mark the end of strings. Otherwise, it leaves the character set up to each C implementation.
C implementations overwhelmingly use ASCII with the character codes 0-127. There may be somewhat more variation in what implementations use with codes 128-255.
CodePudding user response:
C uses a character set for the input source code and another character set for execution of the code.
The character set is fully defined in ISO9899, in 5.2.1 Character sets, page 17.