TXT2LIT(1) General Commands Manual TXT2LIT(1)

txt2lit - conv text to C-lang literal form

txt2lit [-hHV] [-b] [-o ofname] infile
 

~$ txt2lit mylua.lj		#>> output
~$ cat mylua.lj | txt2lit -b	#>> array(binary) mode
~$ echo '1"23\' | txt2lit -o out.txt	#>> "1\"23\\\n"

-hHV
usage, version
-b
output binary array format instead of literal
-o file
set output to file (dfl:stdout)

txt2lit outputs quoted strings for C-lang and byte size.
 
--mylua.lua print("hw") return 0 ~$ txt2lit mylua.lua > mylua.h ~$ cat mylua.h #>>>   "--mylua.lua\n"   "print(\"hw\")\n"   "return 0\n"   / *112* / // almost the same as: // sed -e 's/[\]/&&/g;s/"/\\"/g;s@.*@"&\\n"@g'
 
output code is used as:
 
#include <stdio.h> static const char* str = #include "out.txt" ; // const char str[] = ... if use -b option, c99+ int main(int ac, char** av){   puts("text is:");   puts(str);   return 0; }
 

suc/err == 0/not0

POSIX.1-2001+

Copyright (C) 2021 Momi-g
 

2021-11-23 v1.0.1

lbc(3)