#include <iostream>
#include <string>
std::string
escape_seq (const char * text)
{
std::string res;
unsigned char c;
while (0 != (c = *text ++))
{
if (isascii (c) && isprint (c))
res += c;
else
{
char buf [16];
sprintf (buf, "\\x%02x", c);
res += buf;
}
}
return res;
}
int main()
{
std::cout << escape_seq ("TEST\r\t\n") << std::endl;;
}