Given a counted string (either an array of characters, or a wrapper like std::string), is there a “proper” way to escape and/or unescape it in C or C++, such that “special” characters (like the null character) become C-style-escaped and “normal” characters stay the way they are?
Or do I have to do it by hand?
This is a function to process a single character:
And this is the code to handle a null-terminated string (using the function above):