Why Don't Lowercase Letters Come Right After Uppercase Letters in ASCII?
13 hours ago
- #character-encoding
- #bitwise-operations
- #ASCII
- ASCII uses 7 bits, allowing 128 code points, and its first 128 code points are the same as Unicode.
- There are six characters between uppercase Z and lowercase a, making 26 + 6 = 32, a power of two.
- Uppercase and lowercase letters differ by the 5th bit, corresponding to decimal 32.
- Bitwise operations like AND, OR, and XOR with 32 allow easy case conversion and flipping.
- Masking with 31 (binary 00011111) extracts alphabet position, as c & 31 equals c % 32.