• Simon Marlow's avatar
    Save and restore the codec state when re-decoding · 1e74d272
    Simon Marlow authored
    We previously had an ugly hack to check for a BOM when re-decoding
    some binary data in flushCharBuffer.  The hack was there essentially
    because codecs like UTF-16 have a state, and we had not restored it.
    This patch gives codecs an explicit state, and implemented
    saving/restoring of the state as necessary.  Hence, the hack in
    flushCharBuffer is replaced by a more general mechanism that works for
    any codec with state.
    Unfortunately, iconv doesn't give us a way to save and restore the
    state, so this is currently only implemented for the built-in codecs.
Handle.hs 24.4 KB