How to get a "screen" length of a multibyte string?

kobayashi pg.koba at gmail.com
Sun Nov 25 11:19:18 CET 2012


Hello,

Under platform that has fixed pitch font,
I want to get a "screen" length of a multibyte string

--- sample ---
s1 = u"abcdef"
s2 = u"あいう" # It has same "screen" length as s1's.
print len(s1)  # Got 6
print len(s2)  # Got 3, but I want get 6.
--------------

Abobe can get a "character" length of a multibyte string.
Is there a way to get a "screen" length of a multibyte string?


More information about the Python-list mailing list