MitchTalmadge / ASCII-Data

A small Java library for producing nice looking text-based line-graphs and tables.
Apache License 2.0
120 stars 13 forks source link

Padding malfunction for full-width characters #19

Open windymelt opened 1 year ago

windymelt commented 1 year ago

Hi, I suggest some improvement for this great library.

In East Asian languages, including Japanese, characters are represented with a width twice that of ASCII. This is expressed as full width in Unicode.

This library seems to calculate the amount of padding simply by character count, so if input that includes full-width characters is given, the table display will be corrupted.

Since there are libraries that determine whether Unicode characters are full-width or not[1], it would be possible to render the table accurately by improving the algorithm that calculates the amount of padding.

Actual output:

image

Thanks!

[1] https://unicode-org.github.io/icu-docs/apidoc/dev/icu4j/com/ibm/icu/lang/UCharacter.html#getIntPropertyValue-int-int-