Add explicit casts to unsigned char before calling ctype functions.
Fixes the value range on platforms with signed char.