How to get a "screen" length of a multibyte string?
rosuav at gmail.com
Sun Nov 25 12:12:33 CET 2012
On Sun, Nov 25, 2012 at 9:19 PM, kobayashi <pg.koba at gmail.com> wrote:
> 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?
What do you mean by screen length? Do you mean the length in bytes?
That depends on your encoding. Do you mean width of the displayed
version? That depends on your font.
More information about the Python-list