I came across this in the http_parser library of node.js implementation. When I bitwise-OR an ASCII capitalized character code, it converts into its lowercase version. The lowercase version remains as it is.
Why is a bitwise OR causing the ASCII code to change to the lowercase letter?
5
ASCII has several interesting properties in addition to the one you pointed out. It is relatively simply to ascertain properties about a character. For example, all printable characters are greater than or equal to 32 (010 0000), so if you AND a character with 96 (110 0000) and get zero, it must be nonprintable. Uppercase and lowercase letters differ by a single bit as you noticed:
A = 100 0001, OR with 010 0000 gives a = 110 0001. Same is true for all other letters.
a = 110 0001, AND with 101 1111 gives A = 100 0001. Same is true for all other letters.
This makes it trivial to perform case-insensitive searches via simple bit mask logic. Certainly it is much easier than with some Unicode-encoded characters that need to be decoded into their code points first (7-bit ASCII is also valid UTF-8, good luck other encodings).
Another cool property is the numbers all start with the high-order bits 011. If you see that, and the next bits are 0-9 (0000 – 1001) you can grab those bits and interpret them directly as an integer.
I cannot provide any specific quotes from decades ago back when EBCDIC and ASCII were competing standards, but it is common knowledge in the CS community that ASCII was designed with those specific properties in mind. The idea was to be able to use bit masking and arithmetic an easy way to detect and manipulate human-readable attributes of ASCII characters.
Many devices from ages ago were character-based, such as printers and terminals. Having an easy way for the low-tech devices of the day to be able to decode and use a character without a CPU was a bit deal.