mirror of
https://github.com/fmtlib/fmt.git
synced 2025-12-01 14:49:33 +01:00
Implement basic escaping
This commit is contained in:
@@ -232,7 +232,26 @@ template <
|
||||
FMT_ENABLE_IF(is_std_string_like<typename std::decay<Arg>::type>::value)>
|
||||
OutputIt write_range_entry(OutputIt out, const Arg& v) {
|
||||
*out++ = '"';
|
||||
out = write<Char>(out, v);
|
||||
for (Char c : basic_string_view<Char>(v)) {
|
||||
switch (c) {
|
||||
case '\n':
|
||||
*out++ = '\\';
|
||||
c = 'n';
|
||||
break;
|
||||
case '\r':
|
||||
*out++ = '\\';
|
||||
c = 'r';
|
||||
break;
|
||||
case '\t':
|
||||
*out++ = '\\';
|
||||
c = 't';
|
||||
break;
|
||||
case '"':
|
||||
*out++ = '\\';
|
||||
break;
|
||||
}
|
||||
*out++ = c;
|
||||
}
|
||||
*out++ = '"';
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user