astanin / python-tabulate

Pretty-print tabular data in Python, a library and a command-line utility. Repository migrated from bitbucket.org/astanin/python-tabulate.
https://pypi.org/project/tabulate/
MIT License
2.14k stars 164 forks source link

Unicode can mess up alignment even with wcwidth and WIDE_CHARS_MODE on #108

Closed DragonRulerX closed 3 years ago

DragonRulerX commented 3 years ago

I've found an issue with representing certain Unicode symbols in tabulate and I'm not sure if this is already known given the other two issues seemingly pointing out a similar issue, but not using emoji's in their claims: https://github.com/astanin/python-tabulate/issues/52 https://github.com/astanin/python-tabulate/issues/28

I'm pretty new to using GitHub so please excuse the use of pictures instead of the raw data. I couldn't figure out how to format it so that it wouldn't remove the white space which is the primary point of concern.

Editor Sublime Text3: Image shows logged table in text file image

Discord: Image shows code blocked table image

PowerShell: Image shows logged table in PowerShell (just as reference since my terminal is not Unicode aware, but then things line up) image

This is the raw data: usersid | name | active -----------+---------------+---------- 26 | โ† ๐•€๐•ง๐•’ ๐ŸŽ€ โ„•๐•’ โ† | True 34 | ๐“ข๐“ฎ๐“ฝ๐“ฑ๐ŸŒน | True 32 | ๐““๐“ช๐“ป๐“ด ๐“”๐“ฏ๐“ฏ๐“ฎ๐“ฌ๐“ฝ๐”ƒ | True 1 | Dragon | True

cmccandless commented 3 years ago

Bump. Can confirm this issue in 0.8.7

astanin commented 3 years ago

This issue has been fixed in the current master branch. See also: pull request #58.

image

DragonRulerX commented 3 years ago

I'm not convinced this was fixed. I just pulled 0.8.9 and tried it and my results were still like my original post. I'm not sure if this is a terminal/editor issue or not, but ultimately Discord still doesn't render it properly, but PowerShell does.

joscha commented 3 years ago

I am hitting this issue with the latest version with emojis, specifically ๐Ÿชฆ, ๐Ÿ‘‘ and โœ… .

Jeiwan commented 2 years ago

To have this fixed you need to install widechars: https://github.com/astanin/python-tabulate#wide-fullwidth-cjk-symbols

azumukupoe commented 3 months ago

Emoji modifiers still cause misalignment

+------+---------------------------------+------------------+
| S.NO |              Name               |      Owner       |
+------+---------------------------------+------------------+
|  1   |               ๐Ÿ‘จโ€๐Ÿ’ป                |       S B        |
|  2   |               ๐Ÿ‘จโ€๐Ÿ’ป                |       saku       |
|  3   |               ๐Ÿ‘จโ€๐Ÿ’ป                |      Pranav      |
|  4   |    mรบsica para programar ๐Ÿ‘จโ€๐Ÿ’ป     |     midudev      |
|  5   |            ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ“–๐ŸŽธโค๏ธ             |  waterfall7529   |
|  6   |              ๐Ÿ‘จโ€๐ŸŽ“๐Ÿ‘จโ€๐Ÿ’ป               |    Riko Akami    |
|  7   |             ๐Ÿ‘ทโ€โ™‚๏ธ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ผ              |       naru       |
|  8   | ใƒ†ใƒฌใƒฏใƒผใ‚ฏ BGM๐Ÿ‘จโ€๐Ÿ’ปBoom Bap / Jazz | CHELSEA  Records |
|  9   |             ๐Ÿ”ฅ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‹๏ธโ€โ™€๏ธ              |   shoma ishida   |
|  10  |            ๐Ÿ“š๐Ÿ“–โœ๏ธ๐Ÿ‘จโ€๐Ÿ’ป             |       REN        |
+------+---------------------------------+------------------+

image

hoishing commented 1 month ago

I got the same emoji problem, maybe its related to the terminal font also, I use Sarasa Mono TC font as a work around