cos*_*cos 6 c c++ resources command-line file
请建议一个小的命令行实用程序(用于Windows)将文件从特定目录转换为有效的c文件.也许它可以用批处理命令完成?生成的文件应如下所示:
static const unsigned char some_file[] = {
/* some_file.html */
0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65
}
static const unsigned char some_other_file[] = {
/* some_other_file.png*/
0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x20, 0x20, 0x3c
}
Run Code Online (Sandbox Code Playgroud)
PS请不要建议Perl和Python端口.它们对于这项任务来说太沉重了.
PPS可能有人知道比bin2h更可定制的实用程序,但是比awt更重,更复杂?哪个可以解析几个文件并将它们放到一个C中.同时指定自定义变量名称(使用某种索引文件)也很棒.因此可以将其添加到构建过程中.
Sin*_*nür 14
使用xxd -i file.
我使用Vim附带的那个.例如:
C:\Documents and Settings\user> xxd -i error.log | head -n2
unsigned char error_log[] = {
0x0c, 0x0d, 0x0a, 0x3d, 0x3d, 0x32, 0x30, 0x30, 0x39, 0x2f, 0x35, 0x2f,
另请参见是否可以以1和0查看二进制文件?