Given a standard string object in C++ that is expected to have escape sequences in it, how can I convert that into a quoted version of itself at runtime?
std::string str("Foo said, \"bar\"\n");
Given the above, I want to create a new string, quoted
, that has the following contents:
"\"Foo said, \\\"bar\\\"\\n\""
This is just an example. I need to perform this manipulation with arbitrary strings.
Will I simply have to do this manually for every possible escape sequence?