开发者

Display contents of file as binary

开发者 https://www.devze.com 2022-12-23 18:51 出处:网络
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.

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 开发者_C百科my save or load function.

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

Thanks.


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


Just for fun, using Ruby from the command line:

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号