Message136922
> I'm not sure what you mean by "discard the output".
>
> Calling .reset() should still add the closing sequence to the output
> buffer, if needed.
Incremental encoders don't have any buffer.
Python 3.3a0 (default:3c7792ec4547+, May 26 2011, 00:24:51)
>>> import codecs
>>> enc=codecs.lookup('hz').incrementalencoder()
>>> enc.encode('\u8000')
b'~{R+'
>>> enc.reset()
>>> enc.encode('\u8000')
b'~{R+'
>>> enc.encode('', final=True)
b'~}'
>>> import io
>>> buffer=io.BytesIO()
>>> enc=codecs.lookup('hz').streamwriter(buffer)
>>> enc.write('\u8000')
>>> buffer.getvalue()
b'~{R+'
>>> enc.reset()
>>> buffer.getvalue()
b'~{R+~}'
IncrementalEncoder.reset() may mention that the output is discarded:
.. method:: reset()
Reset the encoder to the initial state. The output is discarded:
use the ``encode('', final=True)`` method to reset the encoder
and to get the output. |
|
Date |
User |
Action |
Args |
2011-05-26 00:14:10 | vstinner | set | recipients:
+ vstinner, lemburg, arigo, amaury.forgeotdarc, hyeshik.chang, gz |
2011-05-26 00:14:09 | vstinner | set | messageid: <1306368849.68.0.326458647267.issue12171@psf.upfronthosting.co.za> |
2011-05-26 00:14:09 | vstinner | link | issue12171 messages |
2011-05-26 00:14:09 | vstinner | create | |
|