Improve hex-to-dec conversion routines

Explicitly handle both `char` and `unsigned char` in `charUnHex` by casting `char` to `unsigned char` to ensure that the range of inputs is always `[0,255]`.