codecs.getencoder encodes entire string ?

nicolas_riesch nicolas.riesch at genevoise.ch
Thu Jul 28 11:42:57 EDT 2005


When I use an encoder function from codecs module, documentation says
that it encodes the object input and returns a tuple (output object,
length consumed).

>>> import codecs
>>> enc=codecs.getencoder('iso-8859-1')
>>> enc(u'asdf')
('asdf', 4)
>>>

I just don't understand why it returns the "length consumed".

Does it means that in some case, the input string can be only partially
converted ?

What can be the use of the "length consumed" value ?


And a last question: can I call this "enc" function from multiple
threads ?




More information about the Python-list mailing list