From a74023698851aafb833171c04d3d30103121e495 Mon Sep 17 00:00:00 2001 From: Barry Revzin Date: Fri, 24 Dec 2021 17:37:40 -0600 Subject: [PATCH] Escaping chars in a less shitty, but actually compiling, way --- include/fmt/format.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 8aae001a..68ae3667 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1693,9 +1693,15 @@ auto write_escaped_string(OutputIt out, basic_string_view str) -> OutputIt template auto write_escaped_char(OutputIt out, Char v) -> OutputIt { + *out++ = v; + return out; +} + +template +auto write_escaped_char(OutputIt out, char v) -> OutputIt { *out++ = '\''; - if (needs_escape(v) && v != '"' || v == '\'') { - out = write_escaped_cp(out, find_escape_result{ + if ((needs_escape(v) && v != '"') || v == '\'') { + out = write_escaped_cp(out, find_escape_result{ &v, &v+1, static_cast(v) }); } else {