现有C ++ Hex转储代码 [英] Off-the-Shelf C++ Hex Dump Code

查看:130
本文介绍了现有C ++ Hex转储代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用网络和串行通讯软件,所以我经常需要有显示或记录十六进制转储数据包的代码。



时间我这样做,我从头写另一个十六进制转储程序。我会再次这样做,但想到我会问这里:有没有任何好的免费十六进制转储代码为C + +在某个地方?



例如:




  • 每行N个字节(其中N是某种可配置的)

  • 可选ASCII / UTF8转储在十六进制

  • 可配置缩进,每行前缀,每行后缀等。

  • 最小依赖(理想情况下,
  • 编辑:说明:我正在寻找代码,我可以轻松地进入我自己的程序写入stderr,stdout或其他这样的输出流。我不是在寻找命令行十六进制转储实用程序。

    解决方案

    unix工具 xxd 作为 vim 的一部分分发,并根据 http://www.vmunix.com/vim/util.html#xxd , xxd的来源为 ftp://ftp.uni-erlangen.de: 21 / pub / utilities / etc / xxd-1.10.tar.gz 。它是用C写的,大约721行。唯一的授权信息是:

      *自由分配,并信用我,
    *赚钱和分享与我,
    *失去钱,不要问我。

    unix工具 hexdump a href =http://gd.tuwien.ac.at/softeng/Aegis/hexdump.html> http://gd.tuwien.ac.at/softeng/Aegis/hexdump.html 。它是用C编写的,可以从源代码编译。它比xxd有点大,并且分布在GPL下。


    I work a lot with network and serial communications software, so it is often necessary for me to have code to display or log hex dumps of data packets.

    Every time I do this, I write yet another hex-dump routine from scratch. I'm about to do so again, but figured I'd ask here: Is there any good free hex dump code for C++ out there somewhere?

    Features I'd like:

    • N bytes per line (where N is somehow configurable)
    • optional ASCII/UTF8 dump alongside the hex
    • configurable indentation, per-line prefixes, per-line suffixes, etc.
    • minimal dependencies (ideally, I'd like the code to all be in a header file)

    Edit: Clarification: I am looking for code that I can easily drop in to my own programs to write to stderr, stdout, or other such output streams. I'm not looking for a command-line hex dump utility.

    解决方案

    The unix tool xxd is distributed as part of vim, and according to http://www.vmunix.com/vim/util.html#xxd, the source for xxd is ftp://ftp.uni-erlangen.de:21/pub/utilities/etc/xxd-1.10.tar.gz. It was written in C and is about 721 lines. The only licensing information given for it is this:

    * Distribute freely and credit me,
    * make money and share with me,
    * lose money and don't ask me.
    

    The unix tool hexdump is available from http://gd.tuwien.ac.at/softeng/Aegis/hexdump.html. It was written in C and can be compiled from source. It's quite a bit bigger than xxd, and is distributed under the GPL.

    这篇关于现有C ++ Hex转储代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆