You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ProgressBarStyle.ASCII does not print only one line. #75
What font are you using? The block character problem may arise if your font does not support specific Unicode box drawing characters.
Try removing the Hangul characters? I guess that since each Hangul takes the space of 2 Latin characters, the width of the progress bar may be wrongly computed. If removing Hangul characters work, then it shows that there should be a general fix towards CJK chars.
I use the font 'D2Coding' that monospace font for developers.
(font docs/download page: github.com/naver/d2codingfont)
As you said, I try removing Hangul characters, then it works! Thank you. Do you have plan to support characters that takes the space of 2 Latin characters?
In the case of ProgressBarStyle.COLORFUL_UNICODE_BLOCK, character '?' is still showed as you expected.
In my case,
ASCII: not support Hangul characters (I really want to use Hangul.)
UNICODE_BLOCK: not support specific Unicode box drawing characters
COLORFUL_UNICODE_BLOCK: not support specific Unicode box drawing characters
I think the way forward is to include a fix to correctly compute the space of width-2 characters (Hangul / Hiragana / Katakana / Chinese characters / etc.)
Thanks for raising this issue! I'll fix this in a later release, but probably not in the coming few weeks.
The principled way to deal with this is to use the Unicode's EastAsianWidth property for each char.
The display width for a char is 1 if it belongs to one of the property N, Na, or H, and 2 if it belongs to W or F.
The display width for any char in class A (ambiguous) is 2 in an East Asian locale but 1 otherwise.
The proposed solution for this is to include a displayWidth(String s, Boolean inEastAsianContext) method that computes the string length instead of just using String::length, similar to C's wcswidth function.
Hi,I also found this problem, but it is not Korean, but Chinese characters. If the printed information exceeds the maximum length of the console, it will wrap. The root cause is to recalculate the length of the string displayed on the console, instead of directly calling String.length to simply count the number of characters as the length.I checked some materials and used the ICU4J.jar library to calculate the string display length. You can refer to the following code:
@fangyuzhong2016 I'm aware of the problem of East Asian characters and this will be fixed in the next version. Thanks!
P.S. In your usage of progressbar, it seems that you have set the max to be 100, but you show the actual number in the extraMessage. You can actually set the actual size with maxHint and it'll behave like this:
Activity
ctongfei commentedon May 19, 2020
Thanks @ImSejin !
Two questions here:
ImSejin commentedon May 20, 2020
I use the font 'D2Coding' that monospace font for developers.
(font docs/download page: github.com/naver/d2codingfont)
As you said, I try removing Hangul characters, then it works! Thank you.
Do you have plan to support characters that takes the space of 2 Latin characters?
In the case of
ProgressBarStyle.COLORFUL_UNICODE_BLOCK, character '?' is still showed as you expected.In my case,
ASCII: not support Hangul characters (I really want to use Hangul.)UNICODE_BLOCK: not support specific Unicode box drawing charactersCOLORFUL_UNICODE_BLOCK: not support specific Unicode box drawing charactersHow should I do? 😢
ctongfei commentedon May 20, 2020
It seems that
D2Codingdoes not support the block drawing characters. You could use another font that does (and also has CJK support, e.g. https://github.com/be5invis/Sarasa-Gothic)I think the way forward is to include a fix to correctly compute the space of width-2 characters (Hangul / Hiragana / Katakana / Chinese characters / etc.)
Thanks for raising this issue! I'll fix this in a later release, but probably not in the coming few weeks.
ImSejin commentedon May 20, 2020
Thanks a lot! Have a nice day.
ctongfei commentedon Sep 15, 2020
The principled way to deal with this is to use the Unicode's
EastAsianWidthproperty for each char.The display width for a char is 1 if it belongs to one of the property
N,Na, orH, and 2 if it belongs toWorF.The display width for any char in class
A(ambiguous) is 2 in an East Asian locale but 1 otherwise.The proposed solution for this is to include a
displayWidth(String s, Boolean inEastAsianContext)method that computes the string length instead of just usingString::length, similar to C'swcswidthfunction.[1] https://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt
[2] http://www.unicode.org/reports/tr11/tr11-36.html
ImSejin commentedon Sep 16, 2020
That's cool!
I will wait for the next update.
fangyuzhong2016 commentedon Nov 29, 2020
Hi,I also found this problem, but it is not Korean, but Chinese characters. If the printed information exceeds the maximum length of the console, it will wrap. The root cause is to recalculate the length of the string displayed on the console, instead of directly calling String.length to simply count the number of characters as the length.I checked some materials and used the ICU4J.jar library to calculate the string display length. You can refer to the following code:
ctongfei commentedon Nov 29, 2020
@fangyuzhong2016 I'm aware of the problem of East Asian characters and this will be fixed in the next version. Thanks!
P.S. In your usage of
progressbar, it seems that you have set themaxto be 100, but you show the actual number in theextraMessage. You can actually set the actual size withmaxHintand it'll behave like this:Correct display length of East Asian characters (fixing #75)
ctongfei commentedon Feb 26, 2021
Fixed (did not pull in
icu4jsince I don't want to pull in such a large library).ctongfei commentedon Mar 13, 2021
Released in version
0.9.1.