On Tuesday 14 February 2006 22:34, Greg Ewing wrote: > Seems to me this is a case where you want to be able > to change encodings in the middle of reading the stream. > You start off reading the data as ascii, and once you've > figured out the encoding, you switch to that and carry > on reading.
Not quite. The proper response in this case is often to re-start decoding with the correct encoding, since some of the data extracted so far may have been decoded incorrectly. A very carefully constructed application may be able to go back and re-decode any data saved from the stream with the previous encoding, but that seems like it would be pretty fragile in practice. There may be cases where switching encoding on the fly makes sense, but I'm not aware of any actual examples of where that approach would be required. -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com