diff --git a/include/fmt/format.h b/include/fmt/format.h index 92acb410..aaea683b 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1613,8 +1613,11 @@ template struct int_writer { make_checked(p, s.size())); } if (prefix_size != 0) p[-1] = static_cast('-'); - out = write(out, basic_string_view(buffer.data(), buffer.size()), - specs); + using iterator = remove_reference_t; + auto data = buffer.data(); + out = write_padded(out, specs, size, size, [=](iterator it) { + return copy_str(data, data + size, it); + }); } void on_chr() { *out++ = static_cast(abs_value); } diff --git a/test/locale-test.cc b/test/locale-test.cc index 87423bce..0e05d148 100644 --- a/test/locale-test.cc +++ b/test/locale-test.cc @@ -70,6 +70,11 @@ TEST(LocaleTest, Format) { fmt::format(small_grouping_loc, "{:L}", max_value())); } +TEST(LocaleTest, FormatDetaultAlign) { + std::locale special_grouping_loc(std::locale(), new special_grouping()); + EXPECT_EQ(" 12,345", fmt::format(special_grouping_loc, "{:8L}", 12345)); +} + TEST(LocaleTest, WFormat) { std::locale loc(std::locale(), new numpunct()); EXPECT_EQ(L"1234567", fmt::format(std::locale(), L"{:L}", 1234567));