I have a text file containing something that behaves like C-strings. For example:
something = "some text\nin two lines\tand tab";
somethingElse = "some text with \"quotes\"";
Fetching things between quotes is not a problem. Problem is that later I'm processing this string and slash escapes makes this hard.
I'd like to decode these strings, process them, then encode them back to C-string literals.
So from that raw input
some text\\with line wrap\nand \"quote\"
I need:
some text\with line wrap
and "quote"
and vice versa.
What I've tried:
I've found some API for processing Python string literals (string_escape
), it is close to what I need, but since I'm processing C-strings it is useless. I've tried find other codecs to match my problem but no luck so far.