[Python-Dev] Improve open() to support reading file starting with an unicode BOM
victor.stinner at haypocalc.com
Fri Jan 8 11:31:37 CET 2010
Le vendredi 08 janvier 2010 01:52:20, Guido van Rossum a écrit :
> And for the other two, perhaps it would make more sense to have
> a separate encoding-guessing function that takes a binary stream and
> returns a text stream wrapping it with the proper encoding?
I choosed to modify open()+TextIOWrapper instead of writing a new function
because I would like to avoid an extra read operation (syscall) on the file.
With my implementation, no specific read operation is needed to detect the
BOM. The BOM is simply checked in the first _read_chunk().
More information about the Python-Dev