Because it's allowed to. The C99 standard says only this about isdigit
, isalpha
, etc:
The functions in this subclause return nonzero (true) if and only if the value of the argument
c
conforms to that in the description of the function.
As to why that's happening in practice, I'm not sure. At a guess, it's using a lookup table shared with all the is*
functions, and masking out all but a particular bit position. e.g.:
static const int table[256] = { ... };
// ... etc ...
int isalpha(char c) { return table[c] & 1024; }
int isdigit(char c) { return table[c] & 2048; }
// ... etc ...