The {{{codecs.StreamRecoder}}} class re-encodes data between 2 character sets. Its constructor expects the information on 2 character sets in different forms. The user should specify the internal character set as a pair of {{{encoder}}} and {{{decoder}}}. She should provide the external character set by supplying class definitions of a codec-specific {{{StreamReader}}} and {{{StreamWriter}}}. Pseudocode of {{{codecs.StreamRecoder}}} of the Python2.5 version: {{{ #!python class StreamRecoder: def __init__(self, stream, e, d, class_sr, class_sw): # internal encoder, decoder^ ^external decoder, encoder self.r = class_sr(stream) self.w = class_sw(stream) ... def read(self): return self.e(self.r.read()) def write(self, data): return self.w.write(self.d(data)) }}} The {{{codecs}}} module defines a function {{{codecs.EncodedFile()}}} that will return an instance of {{{StreamRecoder}}} according to the supplied internal and external character sets. ---- See also: StreamReader, StreamWriter, StreamReaderWriter. ---- CategoryUnicode