39 void write_string(std::ostream &out,
const std::string &s,
bool json)
44 for (
size_t i = 0; i < s.size(); i++)
46 const uint8_t c = uint8_t(s[i]);
51 if (c < 0x20 || c == 0x7f)
66 out.put(
'\\').put(
'"');
68 out.put(
'\\').put(
'\\');
69 else if ((c & 0xe0) == 0xc0 &&
71 (s[i + 1] & 0xc0) == 0x80)
80 (uint8_t(s[i + 1]) & 0xa0) == 0xa0
85 else if ((c & 0xf0) == 0xe0 &&
87 (s[i + 1] & 0xc0) == 0x80 &&
88 (s[i + 2] & 0xc0) == 0x80)
94 else if ((c & 0xf8) == 0xf0 &&
96 (s[i + 1] & 0xc0) == 0x80 &&
97 (s[i + 2] & 0xc0) == 0x80 &&
98 (s[i + 3] & 0xc0) == 0x80)