We define our own routines to classify 8-bit characters (based on US-ASCII charset). This way we bypass most possible problems with different compilation environments.

All functions and macros accept any numbers and if it is necessary, they simply ignore higher bits. It does not matter whether a parameter is signed or uintigned. Parameters are evaluated exactly once, so they can have side-effects.


#define Cupper(x) Ccat(x, _C_UPPER)

Checks for an upper-case character (A-Z).


#define Clower(x) Ccat(x, _C_LOWER)

Checks for a lower-case character (a-z).


#define Calpha(x) Ccat(x, _C_ALPHA)

Checks for an alphabetic character (a-z, A-Z).


#define Cdigit(x) Ccat(x, _C_DIGIT)

Checks for a digit (0-9).


#define Cxdigit(x) Ccat(x, _C_XDIGIT)

Checks for a hexadecimal digit (0-9, a-f, A-F).


#define Cword(x) Ccat(x, _C_WORD)

Checks for an alpha-numeric character or an inner punctation (a-z, A-Z, 0-9, _).


#define Cblank(x) Ccat(x, _C_BLANK)

Checks for a white space (0x20, \t, \n, \r, 0x8, 0xC).


#define Cctrl(x) Ccat(x, _C_CTRL)

Checks for control characters (0x0-0x1F, 0x7F).


#define Cupcase(x) (ucw_c_upper[(byte)(x)])

Convert a letter to upper case, leave non-letter characters unchanged.


#define Clocase(x) (ucw_c_lower[(byte)(x)])

Convert a letter to lower case, leave non-letter characters unchanged.


static inline uint Cxvalue(byte x);

Compute the value of a valid hexadecimal character (ie. passed the Cxdigit() check).