Workaround a broken C locale on Windows
This commit is contained in:
parent
8bd59ec936
commit
3268531bc9
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user