This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author inigoserna
Recipients cben, gpolo, inigoserna
Date 2009-08-26.16:13:20
SpamBayes Score 2.9726221e-13
Marked as misclassified No
Message-id <1251303202.76.0.288694338941.issue6755@psf.upfronthosting.co.za>
In-reply-to
Content
Btw, I don't know if this is the best place to comment it but as it is
somehow related with ncurses...

Other functions I miss a lot are wcwidth() and wcswidth(). 

These functions return the real width (read, cells length in screen) for
unicode strings. 

An example to clarify the issue: one simple Chinese character could need
2 cells on screen, thus len(chinese_unicode_string) won't return the
real screen width needed to show the string.

i.e., len(chinese_unicode_string) != wcswidth(chinese_unicode_string)


Those functions are included into not so old glibc versions (2.2+?), at
least on my Linux systems.

Sadly enough, python doesn't bind them, afaik.
I've tried ctypes but don't work for me (don't know the reason), so I've
written some replacements.

Please look at these files: 

* test_ucs2w.py: benchmarks to different implementations. Most of them,
pure python. Please consider only ucs2w_1x, other are only experiments.

* ucs2w.c: C extension implementation


I think Python could benefit from having these functions in the standard
library. Surely, most simple way should be to bind glibc functions, but
don't know if they exist on other platforms such as MacOS X or Windows.

Neither do I know where they fit... perhaps in unicodedata module.


What do you think? who is the person to convince? (please, don't ask me
to write a PEP, my English is not good enough).
History
Date User Action Args
2009-08-26 16:13:22inigosernasetrecipients: + inigoserna, cben, gpolo
2009-08-26 16:13:22inigosernasetmessageid: <1251303202.76.0.288694338941.issue6755@psf.upfronthosting.co.za>
2009-08-26 16:13:21inigosernalinkissue6755 messages
2009-08-26 16:13:20inigosernacreate