Commit 3268531b authored by Victor Zverovich's avatar Victor Zverovich

Workaround a broken C locale on Windows

parent 8bd59ec9
......@@ -1453,8 +1453,9 @@ template <typename Range> class basic_writer {
};
void on_num() {
int num_digits = internal::count_digits(abs_value);
char_type sep = internal::thousands_sep<char_type>(writer.locale_);
if (!sep) return on_dec();
int num_digits = internal::count_digits(abs_value);
int size = num_digits + sep_size * ((num_digits - 1) / 3);
writer.write_int(size, get_prefix(), specs,
num_writer{abs_value, size, sep});
......
......@@ -44,5 +44,9 @@ TEST(LocaleTest, WFormat) {
EXPECT_EQ(L"1~234~567", fmt::format(loc, L"{:n}", 1234567));
fmt::format_arg_store<fmt::wformat_context, int> as{1234567};
EXPECT_EQ(L"1~234~567", fmt::vformat(loc, L"{:n}", fmt::wformat_args(as)));
auto sep =
std::use_facet<std::numpunct<wchar_t>>(std::locale("C")).thousands_sep();
auto result = sep == ',' ? L"1,234,567" : L"1234567";
EXPECT_EQ(result, fmt::format(std::locale("C"), L"{:n}", 1234567));
}
#endif // FMT_STATIC_THOUSANDS_SEPARATOR
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment