Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26028

Re: Python 2.6 StreamReader.readline()

Date 2012-07-25 11:02 +0200
From Walter Dörwald <walter@livinglogic.de>
Organization LivingLogic AG, Bayreuth/Germany
Subject Re: Python 2.6 StreamReader.readline()
References <65c7dc3b-3dce-45f2-981b-9c8171418f09@googlegroups.com> <d6f4e9-v1r.ln1@satorlaser.homedns.org>
Newsgroups comp.lang.python
Message-ID <mailman.2563.1343208196.4697.python-list@python.org> (permalink)

Show all headers | View raw


On 25.07.12 08:09, Ulrich Eckhardt wrote:

> Am 24.07.2012 17:01, schrieb cpppwner@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[0] is equal to
>> codecs.BOM_UTF16_BE
>> 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.

Servus,
    Walter

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Python 2.6 StreamReader.readline() cpppwner@gmail.com - 2012-07-24 08:01 -0700
  Re: Python 2.6 StreamReader.readline() Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-25 08:09 +0200
    Re: Python 2.6 StreamReader.readline() Walter Dörwald <walter@livinglogic.de> - 2012-07-25 11:02 +0200
      Re: Python 2.6 StreamReader.readline() wxjmfauth@gmail.com - 2012-07-25 03:26 -0700
      Re: Python 2.6 StreamReader.readline() wxjmfauth@gmail.com - 2012-07-25 03:26 -0700

csiph-web