def utf8_recoder(stream, encoding):
 for line in codecs.getreader(encoding)(stream):
  (yield line.encode('utf-8'))

def utf8_recoder ( stream , encoding ) : for line in codecs . getreader ( encoding ) ( stream ) : ( yield line . encode ( 'utf-8' ) )
generator that reads an encoded stream and reencodes to utf-8 .