Internationalization bug?? [Python 2.2.1, RedHat 8.0, Swedish]
Fredrik Lundh
fredrik at pythonware.com
Sun Oct 13 11:55:59 EDT 2002
Paul Watson wrote:
> If len() returns the number of bytes, what can Urban Anjar use to get the
> number of characters?
len() on a string of bytes returns the number of bytes.
to get the number of characters, make sure you're using len() on a
string containing characters.
to convert between byte buffers and strings of characters, use the
encode/decode methods, or the unicode constructor.
chars = unicode(bytes, encoding)
bytes = chars.encode(encoding)
chars = bytes.decode(encoding)
</F>
More information about the Python-list
mailing list