nirum / tableprint

Pretty console printing :clipboard: of tabular data in python :snake:
https://tableprint.readthedocs.io/
MIT License
174 stars 16 forks source link

Irregular Table Width #5

Closed mubaris closed 6 years ago

mubaris commented 7 years ago

I tried to use this module in my script, But got irregular table width.

Screenshot

Can you help on this?

nirum commented 7 years ago

oo interesting I'll take a look

mubaris commented 7 years ago

@nirum Thanks

nirum commented 7 years ago

Hey @mubaris,

So the issue is that it is difficult to identify the display width for international languages using unicode... I found the wcwidth package was able to help with this somewhat. The current version (0.8) gets closer to the correct width, but is still off. I'll keep working on it.

p.s. I like your translation package! super useful utility

nirum commented 7 years ago

other useful links regarding display width:

https://www.recurse.com/blog/74-a-string-of-unexpected-lengths https://stackoverflow.com/questions/30881811/how-do-you-get-the-display-width-of-combined-unicode-characters-in-python-3 https://stackoverflow.com/questions/33351599/how-do-i-get-the-visible-length-of-a-combining-unicode-string-in-python

nirum commented 7 years ago

Just to follow up: it seems like determining the display with of arbitrary unicode strings is quite difficult to do in practice. This blog post (https://norasandler.com/2017/11/02/Around-the-with-Unicode.html) doesn't offer any ideas (see the section 'How long is a string?'), and this blog post (http://blog.jonnew.com/posts/poo-dot-length-equals-two) has similar problems in javascript ...

nirum commented 6 years ago

closing for now