txt2Cstring

Command for converting text to C string notation \n for new line, hexadecimal notation for non printable characters
git clone https://noulin.net/git/txt2Cstring.git
Log | Files | Refs

commit f9a13241b19c38c909100f3d9e739cf8ffc29930
parent c61c3c81d23a776b1e5e7160e70f4dea60a097f7
Author: Remy Noulin <loader2x@gmail.com>
Date:   Sun, 13 Sep 2020 06:53:44 -0400

escape \

package.yml   | 2 +-
txt2Cstring.c | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)

Diffstat:
Mpackage.yml | 2+-
Mtxt2Cstring.c | 2++
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/package.yml b/package.yml @@ -1,6 +1,6 @@ --- name: txt2Cstring - version: 0.0.1 + version: 0.0.2 description: "Convert text file to C string to be inclueded in C code" bin: ./txt2Cstring.c #cflags: -DA -g3 -std=gnu11 -fPIC -pipe diff --git a/txt2Cstring.c b/txt2Cstring.c @@ -30,6 +30,8 @@ int main(int ARGC, char** ARGV) { iter(lines, L) { castS(l,L); + // replace '\' with '\\' + replaceG(l, "\\", "\\\\", 0); replaceG(l, "\"", "\\\"", 0); prependG(l, "\""); appendG(l, "\\n\"");