I need a function to convert \"explicit\" escape sequences into the relative non-printable character. Es:
char str[] = \"\\\\n\";
cout << \"Line1\" <
Here's a cute way to do it on Unixy platforms.
It calls the operating system's echo command to make the conversion.
string convert_escapes( string input )
{
string buffer(input.size()+1,0);
string cmd = "/usr/bin/env echo -ne \""+input+"\"";
FILE * f = popen(cmd.c_str(),"r"); assert(f);
buffer.resize(fread(&buffer[0],1,buffer.size()-1,f));
fclose(f);
return buffer;
}