15 std::ios_base::fmtflags flags = os.flags(std::ios_base::hex);
16 char fill = os.fill(
'0');
19 case -1: os <<
"<end-of-file>";
break;
20 case '\\': os <<
"\\\\";
break;
21 case '\n': os <<
"\\n";
break;
23 if (0 <= c && c <= 127 && std::isprint(c))
25 if (special && strchr(special, c))
30 os <<
"\\x" << std::setw(2) << c;
47 return str_escape(os,
int(uint8_t(c)), special);
51 str_escape(std::ostream& o,
const std::string& str,
const char* special)
std::ostringstream os
The output stream: the corresponding C++ snippet to compile.
std::ostream & str_escape(std::ostream &os, const std::string &str, const char *special=nullptr)
Output a string, escaping special characters.