diff --git a/include/fmt/format.h b/include/fmt/format.h index cfa9cfca..ed8b29eb 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2027,16 +2027,14 @@ auto write_escaped_cp(OutputIt out, const find_escape_result& escape) *out++ = static_cast('\\'); break; default: - if (is_utf8()) { - if (escape.cp < 0x100) { - return write_codepoint<2, Char>(out, 'x', escape.cp); - } - if (escape.cp < 0x10000) { - return write_codepoint<4, Char>(out, 'u', escape.cp); - } - if (escape.cp < 0x110000) { - return write_codepoint<8, Char>(out, 'U', escape.cp); - } + if (escape.cp < 0x100) { + return write_codepoint<2, Char>(out, 'x', escape.cp); + } + if (escape.cp < 0x10000) { + return write_codepoint<4, Char>(out, 'u', escape.cp); + } + if (escape.cp < 0x110000) { + return write_codepoint<8, Char>(out, 'U', escape.cp); } for (Char escape_char : basic_string_view( escape.begin, to_unsigned(escape.end - escape.begin))) { diff --git a/test/std-test.cc b/test/std-test.cc index 29136d04..78f86d5a 100644 --- a/test/std-test.cc +++ b/test/std-test.cc @@ -30,8 +30,7 @@ TEST(std_test, path) { L"\x0428\x0447\x0443\x0447\x044B\x043D\x0448" L"\x0447\x044B\x043D\x0430")), "\"Шчучыншчына\""); - // EXPECT_EQ(fmt::format("{}", std::filesystem::path(L"\xd800")), - // "\\x{d800}"); + EXPECT_EQ(fmt::format("{}", std::filesystem::path(L"\xd800")), "\"\\ud800\""); # endif }