3 ms·
The original 1963 ASCII was upper-case only, so it's a mistake to think of Control as modifying lower-case letters. (It also had slightly different control char
by kps 3y ago
The original 1963 ASCII was upper-case only, so it's a mistake to think of Control as modifying lower-case letters. (It also had slightly different control character assignments, and ↑ ← rather than ^ _ for 0x5E 0x5F, but those don't matter here).
Control consistently toggles the 0x40 bit — so Control+A = 0x40^0x41 = 0x01 and Control+? = 0x40^0x3F = 0x7F = DEL. Of course, ? is typed as Shift+/. Shift consistently toggles the 0x10 bit: Control+Shift+/ = 0x40^0x10^0x2F = 0x7F = DEL. This is why on upper-case-only bit-paired keyboards, right down to the Apple II, you type Shift+P = 0x50^0x10 = 0x40 for @. The manual for the ur-ASCII Teletype Model 33 is explicit about how this works in the keyboard section.
Applying this to space (note Shift+0 is space on a bit-paired keyboard) would give you 0x60, which is out of range for 1963 ASCII. Evidently some early terminal decided this should wrap around to 0x00. (The TTY 33 didn't do this, since it's too complicated to do mechanically.) I had not heard of this before, and always used Control-@ (0x40^0x40 = 0).
Incidentally DEL isn't a control code per se. It's 0x7F because a set bit is a hole on paper tape, so it's the only code such that punching DEL over any another code always results in DEL.
- susam 3y agoThanks for the detailed response. I was aware that early keyboards were uppercase only which results in the bitwise operation for ctrl key being applied to the ASCII code of uppercase characters only. I too use ASCII codes of uppercase characters only in my post although I write the key sequence in lowercase, e.g., ctrl+g along with decimal 71 as the code of the modified character. However, I was not aware that '@' was shift+p in bit-paired keyboards. This revelation resolves a few other mysteries for me, so thank you for sharing this bit. Indeed https://en.wikipedia.org/wiki/File:TTY33ASR.jpg https://en.wikipedia.org/wiki/File:TTY33ASR.jpg shows '@' on shifted 'p'. I do see now how ctrl consistently toggling the 7th LSB explains all the control codes in the ASCII chart. So it is only ctrl+space that sticks out as a special case.