Convert characters in a c string to their escape sequences
I need a function like string ToLiteral(string input) from this post . Such that char *literal = to_literal("asdf\r\n"); Would yield literal ==> "asdf\\r\\n" . I've googled around, but not been able to find anything (guess that I've must be using the wrong terms). However, I assume that a library with this functionality must be out there somewhere... Thank you for the interresting answers. Googling "c string escape function" by the way seems to be the key to obtaining even more examples and GLIB provides g_strescape () which seems to be exactly what I need. There's no built-in function for