3 ms·
The table is a nice way to view ASCII (maybe better transposed?), but the discussion on CTRL-[ for ESC can't be quite right, since then CTRL-; would work too, n
by retzkek 7y ago
The table is a nice way to view ASCII (maybe better transposed?), but the discussion on CTRL-[ for ESC can't be quite right, since then CTRL-; would work too, no?
- Twisol 7y agoWhy's that? In my terminal emulator, CTRL-; just outputs a semicolon. Are there any cases where CTRL plus a character in the first or fourth columns has the same kind of behavior? It seems to me that it's only the elements in the third column that can be used to generate elements of the first column. This is consistent with the description in the article, and still explains why ESC is represented by ^[.
- retzkek 7y agoSpecifically I'm questioning this bit: > Pressing CTRL simply sets all bits but the last 5 to zero in the character that you typed. You can imagine it as a bitwise AND. If that were the case then CTRL-(any column) would result in the first column. Edit: I suppose at this point terminal emulators are just hardcoding in CTRL modifiers rather than the truly emulating what a hardware terminal would have done.
- PhasmaFelis 7y agoThe article says: > Pressing CTRL simply sets all bits but the last 5 to zero in the character that you typed. You can imagine it as a bitwise AND. But it can't be quite that simple, or Ctrl-[, Ctrl-;, and Ctrl-{ would all have the same effect. There must (as you said, and contrary to the article) be additional logic that only zeroes the leading bits if they are "10".
- Twisol 7y agoAhh, I understand. I must have scanned right over that part. As the sibling says, it’s probably the case that terminal emulators have this historic behavior for specific combinations, and not for the more general mechanism of merely setting the high bits of whatever symbol was generated. It’s probably a bit fallacious to test things in an emulator... perhaps the article is correct for the original systems?
- _kst_ 7y agoI vaguely remember using CTRL-7 to get the ASCII BEL character (0x07). This was a long time ago, and I don't see it on any current systems. Another special case: On most keyboards (I suppose it's the terminal emulator that implements it), CTRL-SPACE emits the NUL character. (I find that useful because I use C-@ as the prefix key in tmux.)
- valbaca 7y agoIt appears that it would depend on the keyboard. Some did a subtraction of the code and others did a bitwise AND. Source: https://en.wikipedia.org/wiki/Control_character#How_control_characters_map_to_keyboards https://en.wikipedia.org/wiki/Control_character#How_control_...
- soneil 7y agoThe way I picture it; see the caps set (10) as the default. From there you can shift to the lower-case (11) set, figure (01) set, or control (00) set. But then there's no such thing as CTRL+; - you're switching to two different sets (figures and control) simultaneously. Your keyboard and OS may (should) be able express that, but ascii can't.
- kps 7y agoCTRL would clear the 2⁶ bit. If any sufficiently primitive devices (electromechanical like the Teletype 33) had been made in the lower-case era, you'd probably have got CTRL-; → ; and CTRL-{ → ;