-
Notifications
You must be signed in to change notification settings - Fork 69
Conversation
If the column contains east asian unicode characters, such as "中文". `len` function can't return the right width.
Returns: | ||
String width. | ||
""" | ||
if isinstance(string, Color): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do this without isinstance? I don't like isinstance, it makes code inflexible and hard to use in other libraries. What if someone made something like colorclass where they subclass string/unicode? terminaltables wouldn't work with their library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Robpol86 Yes, isinstance
should be avoid here, but can Color
provide a interface just like the normal str
? I mean, when iterating / decoding the Color
instance, it should return the real value instead of the escaped one, I think this will make things much more easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it won't be so easy since something like sys.stdout.write() iterates the Color instance and that expects the color version. You're free to open an issue/pr in colorclass. Maybe instead you can just use hasattr() or getattr() for value_no_colors?
79f4c4c
to
9bfaf92
Compare
@Robpol86 updated, and I made a rebase for these changes. |
Everything else looks good. Once you fix that one line I'll accept. Thanks! |
@Robpol86 Fixed! |
Fix miscalculation of cjk characters.
Patch is taken from #8, and the tests had been fixed.