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

Fix precision with non-ascii characters #3294

Closed
wants to merge 1 commit into from

Conversation

ShawnZhong
Copy link
Contributor

@ShawnZhong ShawnZhong commented Feb 7, 2023

Fix #3284

Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR but unfortunately it won't work with multibyte code points, e.g.

  fmt::print(">>{:.6}<<\n", "123ж56\xad");

It should print >>123ж56<< but would print >>123ж5<< with this change.

The correct fix is to handle invalid bytes as having width 1.

@ShawnZhong ShawnZhong closed this Feb 12, 2023
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

Successfully merging this pull request may close these issues.

Extra characters printed when formatting invalid UTF-8 with precision
2 participants