2

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.

3
  • @Dave - ?? how is this not programming related? Commented Mar 19, 2010 at 23:00
  • @Eric - you might get better results if you specify what platform/language your are dealing with. Commented Mar 19, 2010 at 23:01
  • The reason why it "appears different" is most probably an encoding problem. Commented Mar 19, 2010 at 23:03

3 Answers 3

4

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

Sign up to request clarification or add additional context in comments.

Comments

2

Just for fun, using Ruby from the command line:

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

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.