7 ms·
Hah, one of the side effects of doing embedded programming is spending a lot of time staring at hex dumps with ascii in them, hex on the left actual characters
by ChuckMcM 10y ago
Hah, one of the side effects of doing embedded programming is spending a lot of time staring at hex dumps with ascii in them, hex on the left actual characters on the right. As a result you start recognizing a lot of ASCII characters when you see the hex codes for them.
I was debugging a library that was a 'native' library for a scripting language and the code seemed to have a much bigger running footprint than I expected. It kept allocating this odd sized buffer, a bit over 13,000 bytes in size. Walking it back to the scripting language interface to C code the buffer it wanted was '32' bytes long but the scripting language was passing it as a string so 0x3332 bytes long. oops! Reading hex and seeing ASCII is a very useful skill to develop.
- schoen 10y agoThe structure of ASCII itself is very useful for this, if you know the ordinal positions of letters in the alphabet. Uppercase letters are 0x40 + position of the letter in the alphabet, so "E", being the 5th letter, is 45, "I", being the 9th letter, is 49, and so on. Lowercase letters are 0x60 + position of the letter in the alphabet, so "e" is 65, "i" is 69, and so on. That also means that you can swap case by flipping a single bit (XOR with 0x20). Finally, digits are 0x30 + the digit's numeric value (including 0), so the digit "5" is 35. (All of these properties were very intentional on the part of ASCII's creators.)
- schoen 10y agoRelatedly, if you want to impress people with the ability to "read binary", and you know that something is plain ASCII text represented in binary, just look at the rightmost 5 bits of every byte. They will be the ordinal position of the letter. "Hello" is 01001000 8 (h) 01100101 5 (e) 01101100 12 (l) 01101100 12 (l) 01101111 15 (o) And when you see all zeroes, it's probably 00100000, the space character.
- pc86 10y agoIf 01001000 is 'h' what is 01101000?
- d4l3k 10y ago01001000 is 'H' and 01101000 is 'h'
- Jarwain 10y agoI think 01001000 was supposed to be 'H'
- komali2 10y ago01001000 is H 01101000 is h http://www.asciitohex.com/ http://www.asciitohex.com/ try and play around with it, it's fun.
- schoen 10y agoI deliberately wrote the "h" in lowercase, even though the ASCII character is uppercase, because I was advising looking only at the five least-significant bits, which won't tell you the case. Sorry for the confusion.
- pc86 10y agoGood clarification thank you :)
- deleted 10y ago[deleted]
- alblue 10y agoI did a talk at the DocklandsLJC on the history of Unicode, and covered the reason for the bit patterns in ASCII. The video was recorded and is available at http://www.docklandsljc.co.uk/2016/06/unicode-cuddly-application-server.html http://www.docklandsljc.co.uk/2016/06/unicode-cuddly-applica... The specific slide regarding ASCII code points is here: https://speakerdeck.com/alblue/a-brief-history-of-unicode?slide=6 https://speakerdeck.com/alblue/a-brief-history-of-unicode?sl...
- kalleboo 10y agoAha, THAT explains ^H, ^C, ^D, ^[ and so forth. I can't believe this eluded me for so long
- davidgay 10y agoConveniently, if you started with a Dragon 32/TRS 80 Color keyboard (and presumably some others of that time?), the symbols above number N was ASCII symbol 0x2N: https://upload.wikimedia.org/wikipedia/commons/5/50/PIC_0119_Dragon_32.JPG https://upload.wikimedia.org/wikipedia/commons/5/50/PIC_0119... The standard US QWERTY keyboard does not quite follow this, though it is close (there's some insertions, substitutions ;)).
- schoen 10y agoI see ![1] at 21, #[3] at 23, $[4] at 24, %[5] at 25, and that's all that literally match. &[7] at 26, ([9] at 28, and )[0] at 29 are off by one in their current QWERTY keyboard positions. If we didn't have ^ and * where they are, then &, (, and ) would be in the right places to continue your pattern. @, ^, and * don't fit the pattern at all. I should also have mentioned this amazingly scholarly piece by Tom Jennings, that explains probably everything there is to know about where everything we've been talking about came from: https://web.archive.org/web/20030201161943/http://www.wps.com/texts/codes/ https://web.archive.org/web/20030201161943/http://www.wps.co... Unfortunately it looks like someone else is now running wps.com so you can't get this directly at its original home anymore.
- gjm11 10y agoYes, some others too. The BBC Micro, for instance. See https://en.wikipedia.org/wiki/Bit-paired_keyboard https://en.wikipedia.org/wiki/Bit-paired_keyboard for some of the history.
- teraflop 10y agoIt's also a side effect of playing The Talos Principle, which has a lot of secret messages in hex-encoded ASCII (and they have to be decoded character-by-character, because you can't copy and paste text from a 3D rendered image).
- Guillaume86 10y agoI used the Google Goggles app of my phone to transcribe these to text, then paste the result in a HEX to ASCII website and voila :)
- nitemice 10y agoI want to play this game even more now.
- teraflop 10y agoAssuming you like puzzles, it's well worth the time and money! Makes a nice complement to SOMA, which touches on very similar themes from a quite different perspective.
- jobu 10y agoReminds me of doing development for old macs. Apple would combine four characters and cast them to an integer - https://en.wikipedia.org/wiki/FourCC https://en.wikipedia.org/wiki/FourCC They used these four-char-codes for error codes, file formats, return values and other random things. After a while I could read and recognize the text from the HEX value of the integers. Even now I still see them pop up sometimes on iOS as error codes from random networking or filesystem errors.
- babuskov 10y ago> Hah, one of the side effects of doing embedded programming or reverse engineering hardware or software :)
- infinite8s 10y agoAlso obscure or undocumented file formats.
- eric_h 10y ago> Reading hex and seeing ASCII is a very useful skill to develop. I found it to be also quite draining when I was reverse engineering an old proprietary software system to develop a tool to import/export data to it. Definitely put my brain in a weird place after spending hours pouring through network dumps and determining how it all worked. It did kind of feel like that scene from the matrix where what's-his-name is staring at the streaming code on the screen, though :P
- nbadg 10y agoThis might be stating the obvious, but I think that probably has more to do with the quantity of ASCII codes, and less to do with the "translation" itself. I have significantly more difficulty reading hex dumps than I ever had reading G-code (that's the machine code that runs CNC mills, most 3d printers, etc). After a few years of working in a shop, I was fluent enough in G-code to be literally talking in it (on occasion, when appropriate) while debugging things. Hex dumps are far, far more intimidating for me to manage.
- mturmon 10y agoIf you debug math for a while, you get similar skills in recognizing the decimal versions of factors like 1/(2 pi) and 1/e. You get a little tingle: that looks familiar ... Sometimes it can save a lot of time chasing down constant factors.
- gsteinb88 10y agoSame goes for me when doing CAD and having to constantly convert between standard & metric -- 254, 508, etc show up in numbers a lot and it gives you a nice hint that it's a "clean" value in the other system. Super useful for reading IC footprints off datasheets that only use one of the two systems
- kens 10y agoOn the other hand, reading octal and seeing ASCII is really tricky. One thing I've realized from working with the Xerox Alto is that octal is really awful and hex is much better. In octal a 16-bit word doesn't split up evenly into bytes, so even recognizing ASCII is difficult. For example, the string "AA" in hex is 0x4141, where each 41 is 'A' - pretty easy. But in octal, it's 040501; 0101 is 'A' but gets multiplied by 4 in the upper byte. (One thing in defense of octal: the 8080/Z-80 instruction set makes much more sense if you look at it in octal.)
- userbinator 10y agox86 is also octal-structured, and I can mentally assemble and disassemble most of the basic instructions from a hexdump by converting between hex and octal: https://news.ycombinator.com/item?id=13045558 https://news.ycombinator.com/item?id=13045558 In octal a 16-bit word doesn't split up evenly into bytes, so even recognizing ASCII is difficult. That's true only if your hexdump is in 16-bit words; in bytes, it's just as straightforward: A-Z is 101 through 132, and a-z is 141 through 172. Incidentally, these are also where x86 puts the single-byte inc/dec/push/pop instructions.
- tyingq 10y agoI believe most linux distros come with 'od', which can dump octal by byte. $ echo 'ABC' | od -bc 0000000 101 102 103 012 A B C \n 0000004
- ChuckMcM 10y agoAs I recall some DEC utilities supported 'split octal' which was base 8 on 8 bit boundaries. With a 16 bit value of 0xffff was represented as 377377 rather than 177777. But their (DEC's) love of octal was why you got 18 bit and 36 bit machines. It is a good example of how language effects design, than the use of hexadecimal vs octal and its impact on computer architecture.
- evv 10y ago"...there's way too much information to decode the Matrix. You get used to it, though. Your brain does the translating. I don't even see the code. All I see is blonde, brunette, redhead."
- 13of40 10y agoI do the opposite. I often have to identify file types in an environment where we're not allowed to install the tools to read them, so I've gotten good at identifying, say, Word 97 documents by opening them in Notepad.
- clort 10y agothat sounds strange, since you have Notepad then I guess you are running Windows, which usually seems to work with file extensions to identify the files.. can you not see the extension? idle programmer mode enabled It seems that it would be possible to have special tools built and installed, which would claim the file types and have an icon with a 'no entry' symbol superimposed on the original type (ie Word icon with a red circle and line through it, for .doc etc..) .. the tool itself could be a simple program that just opened a notification saying '<tool> not installed'
- 13of40 10y ago> can you not see the extension If you see a file that's called "something.doc", can you tell whether it's a flyer for someone's holiday party versus another sample of that malicious RTF that's been going around this week? All the extension does is let Windows put an icon on it and dispatch it to the right application, and if the application supports multiple file formats it does the actual identification by the file header.