TXT2LIT(1)                  General Commands Manual                 TXT2LIT(1)



NAME
       txt2lit - conv text to C-lang literal form

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

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


OPTIONS
       -hHV   usage, version

       -b     output binary array format instead of literal

       -o file
              set output to file (dfl:stdout)

DESCRIPTION
       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;
            }



EXIT_STATUS
       suc/err == 0/not0

CONFORMING_TO
       POSIX.1-2001+

COPYRIGHT
       Copyright (C) 2021 Momi-g


VERSION
       2021-11-23 v1.0.1

SEE_ALSO
       lbc(3)



                                                                    TXT2LIT(1)
