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: 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: =?UTF-8?B?V2FsdGVyIETDtnJ3YWxk?= 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 Subject: Re: Python 2.6 StreamReader.readline() References: <65c7dc3b-3dce-45f2-981b-9c8171418f09@googlegroups.com> In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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