class codecs.StreamRecoder(stream, encode, decode, Reader, Writer, errors)
Creates a StreamRecoder
instance which implements a two-way conversion: encode and decode work on the frontend — the data visible to code calling read()
and write()
, while Reader and Writer work on the backend — the data in stream.
You can use these objects to do transparent transcodings from e.g. Latin-1 to UTF-8 and back.
The stream argument must be a file-like object.
The encode and decode arguments must adhere to the Codec
interface. Reader and Writer must be factory functions or classes providing objects of the StreamReader
and StreamWriter
interface respectively.
Error handling is done in the same way as defined for the stream readers and writers.
Please login to continue.