jazzband / prettytable

Display tabular data in a visually appealing ASCII table format
https://pypi.org/project/PrettyTable/
Other
1.35k stars 154 forks source link

Can not align the text when the text is in chinese. #222

Closed longzhang closed 1 year ago

longzhang commented 1 year ago

When I set the option align with left ,

tb.align = "l"

But it can not work when the text in Chinese .

I thought maybe that's the method of length return is not support the real width we looked.

For example, In Chinese , The strings like "你好" return the length with 2, but it takes 4 width in in practical. In english , the vocabulary width we saw is the same to the result of length method.

WX20221205-164703@2x

hugovk commented 1 year ago

Thanks for the report. Duplicate of https://github.com/jazzband/prettytable/issues/213, see also https://github.com/jazzband/prettytable/issues/49 for some suggestions. PRs welcome to improve this.

longzhang commented 1 year ago

Thank U all . It's so sad that it took my 3 hours to fix it. The style is correct. Chinese font is displayed abnormal in PyCharm. But it looks normal in iTerm.