byte count unicode string

willie willie at
Wed Sep 20 11:40:02 CEST 2006

John Machin:

 >You are confusing the hell out of yourself. You say that your web app
 >deals only with UTF-8 strings. Where do you get "the unicode string"
 >from??? If name is a utf-8 string, as your comment says, then len(name)
 >is all you need!!!

# I'll go ahead and concede defeat since you appear to be on the
# verge of a heart attack :)
# I can see that I lack clarity so I don't blame you.

# By UTF-8 string, I mean a unicode object with UTF-8 encoding:

<type 'unicode'>
 >>> repr(ustr)

# The database API expects unicode objects:
# A template query, then a variable number of values.
# Perhaps I'm a victim of arbitrary design decisions :)

More information about the Python-list mailing list