STINNER Victor <victor.stin...@gmail.com> added the comment: > Martin: I agree that there are going to be cases where it is not > correct because the terminal does something strange, but what we > need is something that gets as close as possible to what the > terminal is likely to be doing
Can't we expose wcswidth() as locale.strwidth() with a recipe explaining how to use unicodedata to get a "correct" result? At least until everyone implements correctly Unicode and Unicode stops evolving? :-) -- For unicodedata, a function to get the width of a string would be more convinient than unicodedata.east_asian_width(): >>> import unicodedata >>> unicodedata.east_asian_width('abc') Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: need a single Unicode character as parameter >>> 'abc'.ljust(unicodedata.east_asian_width(' ')) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'str' object cannot be interpreted as an integer The function posted in msg155361 looks like east_asian_width() is not enough to get the width in columns of a single character. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12568> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com