ohh it adjusts for upper lower.

No, it doesn't.

It simply ignores upper or lower case.

ASCII digits '0' to '9' have hex values 0x30 to 0x39.

ASCII digits 'A' to 'F' have hex values 0x41 to 0x46 or 'a' to 'f' 0x61 to 66.

If an ASCII hex digit is greater than 9

if(ascii > 0x39)

, then subtracting 7 from it (assuming it is A to F or a to f) will convert the least significant four bits of it to 0x0A to 0x0F, so that ANDing it with 15 will yield the hex digit represented by the ASCII character.

Of course, you can give it any ASCII character (including punctuation), and it will attempt to turn it into hex.