reencoding trap now depends on the *current* encoder state.

previously it didn't depend on the encoder state at all, resulting in
the incorrect output when the encoder has a complex state.
this directly affects ISO 2022 encodings in the development.