Instead of using existing utilities, you may try below conversion using boolean operation:
To upper case:
char upperChar = 'l' & 0x5f
To lower case:
char lowerChar = 'L' ^ 0x20
How it works:
Binary, hex and decimal table:
------------------------------------------
| Binary | Hexadecimal | Decimal |
-----------------------------------------
| 1011111 | 0x5f | 95 |
------------------------------------------
| 100000 | 0x20 | 32 |
------------------------------------------
Let's take an example of small l
to L
conversion:
The binary AND operation: (l & 0x5f)
l
character has ASCII 108 and 01101100
is binary represenation.
1101100
& 1011111
-----------
1001100 = 76 in decimal which is **ASCII** code of L
Similarly the L
to l
conversion:
The binary XOR operation: (L ^ 0x20)
1001100
^ 0100000
-----------
1101100 = 108 in decimal which is **ASCII** code of l