...
Note that the two different ways a character is used as an int
(as an unsigned char
+ EOF
, or as a plain char
, converted to int
) can lead to confusion. For example, isspace('\200')
results in undefined behavior when char
is signed.
unsigned char
- Used internally for string comparison functions, even though these operate on character data. Consequently, the result of a string comparison does not depend on whether plain
char
is signed. - Used for situations where the object being manipulated might be of any type, and it is necessary to access all bits of that object, as with
fwrite()
.
Unlike other integer types, unsigned char
has the unique property that (quoting from Section 6.2.6.1 of C99):
...
That is, objects of type unsigned char
may have no padding bits and thus no trap representation. Thus, non-bit field objects of any type may be copied into an array of unsigned char
(e.g., via memcpy()
) and have their representation examined one byte at a time.
...
.
wchar_t
- Wide characters are used for natural-language character data.
...