standard c library for escaping a string.
- by rampion
Is there a standard C library function to escape C-strings?
For example, if I had the C string:
char example[] = "first line\nsecond line: \"inner quotes\"";
And I wanted to print
"first line\nsecond line: \"inner quotes\""
Is there a library function that will do that transformation for me? Rolling my own just seems a little silly.
Bonus points if I can give it a length to escape (so it stops before or beyond the \0).