def stream_decode_response_unicode(iterator, r):
if r.encoding is None:<EOL><INDENT>for item in iterator:<EOL><INDENT>yield item<EOL><DEDENT>return<EOL><DEDENT>decoder = codecs.getincrementaldecoder(r.encoding)(errors='<STR_LIT:replace>')<EOL>for chunk in iterator:<EOL><INDENT>rv = decoder.decode(chunk)<EOL>if rv:<EOL><INDENT>yield rv<EOL><DEDENT><DEDENT>rv = decoder.decode(b'<STR_LIT>', final=True)<EOL>if rv:<EOL><INDENT>yield rv<EOL><DEDENT>
Stream decodes a iterator.