views:

36

answers:

3

Is there a good way to display the contents of a file as binary?

I am creating a program that needs to save and load a 2D arrays from a files. When loading a saved file the result appears different. I need to be able to view the contents of the saved file in plain binary to tell if my problem in in my save or load function.

Is there a program like octal dump but is binary dump?

Thanks.

+1  A: 

On linux/unix (or Windows + cygwin) there is the "od" utility which dumps files in many formats.

E.g. hexadecimal:

od -t x1 file...

I hope it may help you. Regards

Giuseppe Guerrini
cygwin is not required: http://unxutils.sourceforge.net/
Ignacio Vazquez-Abrams
+1  A: 

Having the raw binary dump is too overwhelming for most people. Consider using od -x, or if you need a more specific format then examine the various options for -t.

Ignacio Vazquez-Abrams
A: 

Just for fun, using Ruby from the command line:

cat file | ruby -e "puts STDIN.read.unpack('B*')[0].scan(/[01]{8}/).join(' ')"
Todd Yandell