Python 2.6 StreamReader.readline()
walter at livinglogic.de
Wed Jul 25 11:02:01 CEST 2012
On 25.07.12 08:09, Ulrich Eckhardt wrote:
> Am 24.07.2012 17:01, schrieb cpppwner at gmail.com:
>> reader = codecs.getreader(encoding)
>> lines = 
>> with open(filename, 'rb') as f:
>> lines = reader(f, 'strict').readlines(keepends=False)
>> where encoding == 'utf-16-be'
>> Everything works fine, except that lines is equal to
>> Is this behaviour correct, that the BOM is still present?
> Yes, assuming the first line only contains that BOM. Technically it's a
> space character, and why should those be removed?
If the first "character" in the file is a BOM the file encoding is
probably not utf-16-be but utf-16.
More information about the Python-list