-
Notifications
You must be signed in to change notification settings - Fork 63
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
getopts should use grapheme clusters for text alignment #7
Comments
Perhaps |
The original example here looks correct. However I was able to see the bug by using a different character in one of the options, in my case \u{3042}. Also:
This doesn't seem to happen any more. |
This is interesting issue. Never thought about grapheme length in rendering context. Is it possible to solve this issue in a clean way for terminal emulators ? |
This is now https://crates.io/crates/unicode-width |
@SimonSapin Looks like there are two versions to compute the display width. |
Many CJK characters are typically two columns wide in monospace fonts. The crate above will tell you, based on the Unicode character database. But some characters have an "ambiguous width": they make take 2 or 1 column depending on whether you’re in a "CJK context", which is not all that well defined. In the Windows console, it appears to depend on the Windows locale. The difference between these two methods is how ambiguous characters are counted. https://www.unicode.org/reports/tr11/ has all of the background. But the actual rendering will depend on a bunch of stuff including which fonts are installed. Still, just using |
One additional note, In the PR #71 I am using crate attribute:
What does this error message mean ? Should we use the Thanks, |
No, you should probably not use unstable features in this crate since that would prevent using it with Rust Stable, whereas previous versions can. |
use unicode-width instead of len() or grapheme cluster #7.
This was implemented in #71 and released as |
Issue by Kimundi
Saturday Mar 23, 2013 at 13:52 GMT
For earlier discussion, see rust-lang/rust#5516
This issue was labelled with: A-libs, E-easy in the Rust repository
It should at minimum align to number of codepoints (characters), (and now that PR #8710 has landed, it should be doing that minimum), but the only correct thing would be to align to grapheme clusters.
test case
current output:
Note that in addition to things failing to line up, it is also cutting off the end of the text for the brûlée case. That issue should also be fixed.
The text was updated successfully, but these errors were encountered: