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


Groups > comp.lang.python > #26028

Re: Python 2.6 StreamReader.readline()

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <walter@livinglogic.de>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.05; 'character,': 0.07; "'rb')": 0.09; 'correct,': 0.09; 'subject:()': 0.09; 'cc:addr:python-list': 0.10; 'encoding': 0.15; "skip:' 30": 0.15; 'eckhardt': 0.16; 'present?': 0.16; 'wrote:': 0.17; 'assuming': 0.22; 'fine,': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'lines': 0.28; 'behaviour': 0.29; 'probably': 0.29; 'file': 0.32; 'equal': 0.33; 'except': 0.36; 'but': 0.36; 'should': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'received:10': 0.38; 'space': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'first': 0.61; 'received:217': 0.68; 'received:10.10': 0.75; 'received:10.10.10': 0.84; 'subject:skip:S 20': 0.91; 'technically': 0.91
X-Virus-Scanned Debian amavisd-new at rhein.livinglogic.de
Date Wed, 25 Jul 2012 11:02:01 +0200
From Walter Dörwald <walter@livinglogic.de>
Organization LivingLogic AG, Bayreuth/Germany
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20120713 Thunderbird/14.0
MIME-Version 1.0
To Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com>
Subject Re: Python 2.6 StreamReader.readline()
References <65c7dc3b-3dce-45f2-981b-9c8171418f09@googlegroups.com> <d6f4e9-v1r.ln1@satorlaser.homedns.org>
In-Reply-To <d6f4e9-v1r.ln1@satorlaser.homedns.org>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2563.1343208196.4697.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1343208196 news.xs4all.nl 6846 [2001:888:2000:d::a6]:53086
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:26028

Show key headers only | 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