[issue33578] cjkcodecs missing getstate and setstate implementations

INADA Naoki report at bugs.python.org
Tue Jun 5 04:20:37 EDT 2018


INADA Naoki <songofacandy at gmail.com> added the comment:

ISO-2022-* is "stateful" encoding.  It uses escape sequence to change state.
So keeping only `pending` is not enough.

>>> enc.encode("abcあいう")
b'abc\x1b$B$"$$$&'
>>> enc.getstate()
0
>>> enc.encode("abc")
b'\x1b(Babc'

>>> enc.encode("abcあいう")
b'abc\x1b$B$"$$$&'
>>> enc.getstate()
0
>>> enc.setstate(0)
>>> enc.encode("abc")
b'abc'

I don't know much about other encodings.

----------
nosy: +inada.naoki

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33578>
_______________________________________


More information about the Python-bugs-list mailing list