3 ms·
> ...Look at the ascii chart by bit pattern and the characters will suddenly make sense. Could you elaborate on what does the bit pattern reveal? For example,
by zoomablemind 4y ago
> ...Look at the ascii chart by bit pattern and the characters will suddenly make sense.
Could you elaborate on what does the bit pattern reveal?
For example, I understand that Ctrl-C generates 0x30, which stands for ETX (end of transmission), but what is it there in 011?
- aap_ 4y agoCtrl clears the highest two bits. E.g. @ (ascii 0x40) turns into ^@/NUL (ascii 0x00). Similarly C (0x43) -> ^C/ETX (0x03). Older terminals (like the VT05) used bit-pairing also with shift. They just flipped some bits depending on the upper two bits. Compare column 2 with 3 in the linked graphic, and 4,5 with 6,7.
- jart 4y agoI don't know if the chart helps, but #define CTRL(x) ((x) ^ 0100) // e.g. 'C' ^ 0100 is 3 // e.g. '@' ^ 0100 is 0 // e.g. 'M' ^ 0100 is 13 a.k.a. \r a.k.a. enter I like this explanation better. It also explains what notation like ^C means. It's shorthand for 0100^C.
- jagged-chisel 4y agoExpanding your overloaded operator: Crtl-C is shorthand for 0100 xor ‘C’ Also, the 0 prefix means this is a base-8 (octal) number
- gumby 4y agoJust run your eye horizontally to see that toggling only a couple of bits move you between ^C, C, and c (back when ASCII was formalized few terminals supported lower case, and six bit character sets were common).