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

1615: Fix bug in getCJKAdjustedLength() that double counts supplement… #1616

Conversation

gwalbran
Copy link
Contributor

@gwalbran gwalbran commented Feb 27, 2022

…ary code points

getCJKAdjustedLength calculates the column width of text strings.

But it operates on chars which causes it to double count supplementary code
points. Supplimentary code points have a high and a low code unit(char).

This commit reworks this logic to be based on code points. The code assembles
the code points by hand as String.codePoints() was only added in 1.8 and
picocli has a source level of 1.5

closes #1615

@remkop remkop added this to the 4.7 milestone Feb 27, 2022
Copy link
Owner

@remkop remkop left a comment

Choose a reason for hiding this comment

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

This looks great, thank you very much!
I am working on some improvements to the build (currently CI is broken), and I will merge this PR after I get the build fixed.
Thank you again for the contribution!

…ary code points

getCJKAdjustedLength calculates the column width of text strings.

But it operates on chars which causes it to double count supplementary code
points. Supplimentary code points have a high and a low code unit(char).

This commit reworks this logic to be based on code points. The code assembles
the code points by hand as String.codePoints() was only added in 1.8 and
picocli has a source level of 1.5
@remkop remkop force-pushed the 1615-fix-getCJKAdjustedLength-for-supplementary-code-points branch from 4ccad5b to 843b1bb Compare March 2, 2022 07:33
@remkop remkop merged commit d567eff into remkop:main Mar 2, 2022
remkop added a commit that referenced this pull request Mar 2, 2022
@remkop
Copy link
Owner

remkop commented Mar 2, 2022

Merged. Thank you again for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getCJKAdjustedLength is miscalculating for supplementary code points
2 participants