4 ms·
Look at the ascii chart by bit pattern and the characters will suddenly make sense. Here’s an old chart from the 60s that explains it: https://programesecure.
by gumby 4y ago
Look at the ascii chart by bit pattern and the characters will suddenly make sense. Here’s an old chart from the 60s that explains it:
https://programesecure.com/ascii-values-table-generator-in-c/ https://programesecure.com/ascii-values-table-generator-in-c...
Unfortunately if you just see the character codes with the decimal, hex, and octal next to them this logic is obscured. Remember, it had to be implementable in (mechanical!) hardware.
- 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).
- SheetPost 4y ago> Here’s an old chart from the 60s that explains it eh, the article linked does a very poor job of an explanation of ASCII And no wonder, it's a deep subject - if you want answers the you want to watch this talk: https://m.youtube.com/watch?v=_mZBa3sqTrI https://m.youtube.com/watch?v=_mZBa3sqTrI
- gumby 4y agoThat site didn’t let me link straight to the chart. I’ve seen that chart for years (decades) but that was the only one I could quickly find on the web.