Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thousands separator is buggy (L specifier) #1927

Closed
rbrich opened this issue Oct 10, 2020 · 1 comment
Closed

Thousands separator is buggy (L specifier) #1927

rbrich opened this issue Oct 10, 2020 · 1 comment

Comments

@rbrich
Copy link
Contributor

rbrich commented Oct 10, 2020

L specifier with en_US locale gives wrong output in some cases:

#include <fmt/format.h>
#include <locale>

int main() {
  std::locale::global(std::locale("en_US.UTF-8"));
  fmt::print("    256  => {:>10L}\n", 256);
  fmt::print("   1000  => {:>10L}\n", 1000);
  fmt::print("  34000  => {:>10L}\n", 34000);   // =>   134,000
  fmt::print(" 123456  => {:>10L}\n", 123456);  // =>  ,123,456
  fmt::print("   -256  => {:>10L}\n", -256);    // =>      ,256
  fmt::print("  -1000  => {:>10L}\n", -1000);
  fmt::print(" -34000  => {:>10L}\n", -34000);  // =>  --34,000
  fmt::print("-123456  => {:>10L}\n", -123456); // => -,123,456
}

https://godbolt.org/z/4ax5Tr

Minimal reproducer (the width and alignment doesn't matter):

fmt::format(std::locale("en_US.UTF-8"), "{:L}", -256);
@vitaut
Copy link
Contributor

vitaut commented Oct 10, 2020

Good catch, thanks. Some of these are already fixed in 7.0.3 and the issue with a sign is fixed in a5e7e7d.

@vitaut vitaut closed this as completed Oct 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants