# hex_dump **Repository Path**: etberzin/hex_dump ## Basic Information - **Project Name**: hex_dump - **Description**: 一个简单的命令行工具,读入并以十六进制文本的形式输出文件的每个字节。 - **Primary Language**: C - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2018-05-06 - **Last Updated**: 2022-09-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Hex_Dump (v1.0) ========= 一个简单的命令行工具,读入并以十六进制文本的形式输出文件的每个字节。 ## 1.概述 命令行参数: ```plain text hex_dump [length (uint) [start (uint)] ] file_path - path to the target file. length - count of bytes which should be dumped. start - start position of the file pointer. ``` 目的是能方便的查看文件的二进制信息,比如文本文件编码后的结果,生成的十六进制文本串可以直接粘贴到代码中作为数组的初始化内容使用。 实际使用效果如下: ```shell $ hex_dump test.txt {0xd2, 0xbb, 0xb6, 0xfe, 0xc8, 0xfd, 0xcb, 0xc4, 0xce, 0xe5, 0xc1, 0xf9, 0xc6, 0xdf, 0xb0, 0xcb, 0xbe, 0xc5, 0xca, 0xae, } Dumped Length : 20 => 20.00 byte ``` 可以设置要输出的字节数和文件指针的起始位置: ```shell $ hex_dump hex_dump.c 10 30 {0x64, 0x6f, 0x77, 0x73, 0x29, 0xa, 0x2f, 0x2f, 0x68, 0x65, } Dumped Length : 10 => 10.00 byte Start At : 30 Total File Size : 2835 => 2.77 kb ``` ## 2.编译 使用的编译器是 [tcc version 0.9.27 (i386 Windows)](https://bellard.org/tcc/) 编译指令: ```shell tcc hex_dump.c ```