mirror of
https://github.com/fmtlib/fmt.git
synced 2025-08-01 11:44:46 +02:00
Don't overescape wide strings
This commit is contained in:
@@ -232,11 +232,11 @@ template <typename Char> inline bool is_printable_ascii(Char c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template <
|
||||||
typename Char, typename OutputIt, typename Arg,
|
typename Char, typename OutputIt, typename T,
|
||||||
FMT_ENABLE_IF(is_std_string_like<typename std::decay<Arg>::type>::value)>
|
FMT_ENABLE_IF(is_std_string_like<typename std::decay<T>::type>::value)>
|
||||||
OutputIt write_range_entry(OutputIt out, const Arg& v) {
|
OutputIt write_range_entry(OutputIt out, const T& str) {
|
||||||
*out++ = '"';
|
*out++ = '"';
|
||||||
for (Char c : basic_string_view<Char>(v)) {
|
for (Char c : basic_string_view<Char>(str)) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '\n':
|
case '\n':
|
||||||
*out++ = '\\';
|
*out++ = '\\';
|
||||||
@@ -257,6 +257,7 @@ OutputIt write_range_entry(OutputIt out, const Arg& v) {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (is_printable_ascii(c)) break;
|
if (is_printable_ascii(c)) break;
|
||||||
|
if (sizeof(Char) != 1 && c >= 0x80) break;
|
||||||
out = format_to(out, "\\x{:02x}", c);
|
out = format_to(out, "\\x{:02x}", c);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user