News for hackers. Stuff that matters.
Re:1213486160 has a friend: 1195725856 by ChuckMcM on Thursday December 08, 2016 @02:15PM (#13133179)
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.

Re:1213486160 has a friend: 1195725856 by schoen on Thursday December 08, 2016 @02:51PM (#13133600)
The 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.)

Re:1213486160 has a friend: 1195725856 by schoen on Thursday December 08, 2016 @02:59PM (#13133714)
Relatedly, 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.

Re:1213486160 has a friend: 1195725856 by alblue on Friday December 09, 2016 @04:30AM (#13137683)
I 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-applica...

The specific slide regarding ASCII code points is here:

https://speakerdeck.com/alblue/a-brief-history-of-unicode?sl...

Re:1213486160 has a friend: 1195725856 by kalleboo on Friday December 09, 2016 @09:11AM (#13138805)
Aha, THAT explains ^H, ^C, ^D, ^[ and so forth. I can't believe this eluded me for so long
Re:1213486160 has a friend: 1195725856 by pc86 on Thursday December 08, 2016 @03:08PM (#13133793)
If 01001000 is 'h' what is 01101000?
Re:1213486160 has a friend: 1195725856 by schoen on Thursday December 08, 2016 @03:30PM (#13133994)
I 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.
Re:1213486160 has a friend: 1195725856 by pc86 on Friday December 09, 2016 @10:31AM (#13139250)
Good clarification thank you :)
Re:1213486160 has a friend: 1195725856 by komali2 on Thursday December 08, 2016 @03:14PM (#13133857)
01001000 is H

01101000 is h

http://www.asciitohex.com/ try and play around with it, it's fun.

Re:1213486160 has a friend: 1195725856 by Jarwain on Thursday December 08, 2016 @03:12PM (#13133842)
I think 01001000 was supposed to be 'H'
Re:1213486160 has a friend: 1195725856 by d4l3k on Thursday December 08, 2016 @03:12PM (#13133839)
01001000 is 'H' and 01101000 is 'h'
Re:1213486160 has a friend: 1195725856 by davidgay on Thursday December 08, 2016 @11:04PM (#13136581)
Conveniently, 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...

The standard US QWERTY keyboard does not quite follow this, though it is close (there's some insertions, substitutions ;)).

Re:1213486160 has a friend: 1195725856 by schoen on Friday December 09, 2016 @01:28AM (#13137084)
I 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.co...

Unfortunately it looks like someone else is now running wps.com so you can't get this directly at its original home anymore.

Re:1213486160 has a friend: 1195725856 by gjm11 on Friday December 09, 2016 @06:01AM (#13138007)
Yes, some others too. The BBC Micro, for instance. See https://en.wikipedia.org/wiki/Bit-paired_keyboard for some of the history.
Re:1213486160 has a friend: 1195725856 by jobu on Thursday December 08, 2016 @03:10PM (#13133824)
Reminds me of doing development for old macs. Apple would combine four characters and cast them to an integer - 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.

Re:1213486160 has a friend: 1195725856 by teraflop on Thursday December 08, 2016 @03:09PM (#13133813)
It'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).
Re:1213486160 has a friend: 1195725856 by Guillaume86 on Thursday December 08, 2016 @06:19PM (#13135254)
I 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 :)
Re:1213486160 has a friend: 1195725856 by nitemice on Thursday December 08, 2016 @07:14PM (#13135586)
I want to play this game even more now.
Re:1213486160 has a friend: 1195725856 by teraflop on Thursday December 08, 2016 @10:29PM (#13136451)
Assuming 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.
Re:1213486160 has a friend: 1195725856 by eric_h on Thursday December 08, 2016 @03:40PM (#13134076)
> 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

Re:1213486160 has a friend: 1195725856 by nbadg on Thursday December 08, 2016 @10:46PM (#13136511)
This 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.
Re:1213486160 has a friend: 1195725856 by kens on Thursday December 08, 2016 @06:30PM (#13135333)
On 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.)

Re:1213486160 has a friend: 1195725856 by ChuckMcM on Friday December 09, 2016 @01:14PM (#13140527)
As 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.

Re:1213486160 has a friend: 1195725856 by userbinator on Thursday December 08, 2016 @08:45PM (#13136009)
x86 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

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.

Re:1213486160 has a friend: 1195725856 by tyingq on Friday December 09, 2016 @10:04PM (#13143765)
I 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
Re:1213486160 has a friend: 1195725856 by mturmon on Thursday December 08, 2016 @05:04PM (#13134710)
If 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.

Re:1213486160 has a friend: 1195725856 by gsteinb88 on Thursday December 08, 2016 @09:18PM (#13136171)
Same 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
Re:1213486160 has a friend: 1195725856 by babuskov on Thursday December 08, 2016 @03:32PM (#13134000)
> Hah, one of the side effects of doing embedded programming

or reverse engineering hardware or software :)

Re:1213486160 has a friend: 1195725856 by infinite8s on Thursday December 08, 2016 @07:20PM (#13135613)
Also obscure or undocumented file formats.
Re:1213486160 has a friend: 1195725856 by 13of40 on Friday December 09, 2016 @01:36AM (#13137109)
I 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.
Re:1213486160 has a friend: 1195725856 by clort on Friday December 09, 2016 @04:47AM (#13137759)
that 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'

Re:1213486160 has a friend: 1195725856 by 13of40 on Friday December 09, 2016 @09:33AM (#13138925)
> 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.

Re:1213486160 has a friend: 1195725856 by evv on Thursday December 08, 2016 @08:41PM (#13135986)
"...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."