I want something like
string magic(char c);
so that when I do
std::cout << magic(c);
I get:
- The character itself for printing ASCII characters;
- A 2/3-letter ASCII code for other ASCII characters (e.g.
"NUL"
,"BEL"
,"LF"
etc.) - Anything reasonable when c is non-ASCII (8th bit on).
What should I use? (It doesn't have to be a function necessarily.)