0

I have worked with xxd utility which translates binary to ascii format and vice versa, but I am not really sure what it dos behind the scene.

Assume I have the following hexdump:

0100 0000 0500 0000 0000 0000 0000 0000  ................

Clearly this is in ascii format. What is the difference between saving this line on disk as is VS saving it in binary format? how is a single character of 0 stored on disk in ascii VS binary format?

Joe
  • 1
  • Save the character `0` in a text file and run it through xxd. `Clearly this is in ascii format.` Yeah, because xxd converted the binary data to a hexadecimal representation. Its not stored in this format though. – tkausl Mar 03 '19 at 23:29
  • @tkausl what's `0` in binary? does it even make sense to ask this question – Joe Mar 03 '19 at 23:31
  • `0` in binary is most likely 48. But thats the _character_ 0 which you see on the screen. The _value_ 0 is literally that, 0. – tkausl Mar 03 '19 at 23:33
  • @tkausl so what does xxd covert `0` to, can I write in direct binary (and not use xxd for conversion) using the characters on keyboard? – Joe Mar 03 '19 at 23:35
  • xxd converts the binary value `0` to the character sequence `00` which is a hexadecimal representation of this value. No, you can't type binary on your keyboard. – tkausl Mar 03 '19 at 23:37
  • what is xxd doing that I can't type on my keyboard, i'm still lost on that little border between how ascci is translated in to binary – Joe Mar 03 '19 at 23:42
  • xxd is doing some math on the numbers to convert them, you can't type them directly. Take a look at the [ascii table](http://www.asciitable.com/) – tkausl Mar 03 '19 at 23:44

0 Answers0