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

field alignment issue with trailing zero #2830

Closed
tstack opened this issue Mar 23, 2022 · 1 comment
Closed

field alignment issue with trailing zero #2830

tstack opened this issue Mar 23, 2022 · 1 comment

Comments

@tstack
Copy link

tstack commented Mar 23, 2022

fmt version: 8.1.1 and top-of-tree

There seems to be an issue with aligned fields where an extra leading space is added when the value has a trailing zero. To replicate, I added the following tests to an xchar-test.cc unit test:

  EXPECT_EQ(L"   1,235", fmt::format(std::locale("en_US.UTF-8"), L"{:8L}", rint(1234.56)));
  EXPECT_EQ(L"   1,230", fmt::format(std::locale("en_US.UTF-8"), L"{:8L}", rint(1230.0)));

The first test passes, but the second one shows the issue. A value of:

"    1,230"

is returned by fmt::format() instead of

"   1,230"

I'm not sure if the locale really affects it, I haven't played with the parameters that much. Let me know if you need more information.

@vitaut
Copy link
Contributor

vitaut commented Apr 12, 2022

Fixed in 192f79a. Thanks for reporting!

@vitaut vitaut closed this as completed Apr 12, 2022
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