Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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.086 X-Spam-Evidence: '*H*': 0.84; '*S*': 0.01; 'anyway.': 0.05; 'insert': 0.05; 'utf-8': 0.07; '-tkc': 0.16; 'csv': 0.16; 'from:name:tim chase': 0.16; 'prefixed': 0.16; 'wrote:': 0.18; 'byte': 0.24; 'specifies': 0.24; 'purposes': 0.26; 'excel': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'returned': 0.30; 'file': 0.32; 'actual': 0.34; 'subject:the': 0.34; 'subject:from': 0.34; 'but': 0.35; 'charset:us-ascii': 0.36; 'to:addr:python- list': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'remove': 0.60; "you're": 0.61; 'first': 0.61; 'customers': 0.66; 'idiots': 0.84; 'protocol,': 0.84; 'reading,': 0.84; 'received:50.22': 0.84; 'sniffing': 0.84; 'writing,': 0.84 Date: Thu, 16 Jan 2014 19:40:05 -0600 From: Tim Chase To: python-list@python.org Subject: Re: Guessing the encoding from a BOM In-Reply-To: References: <1389901049.40172.YahooMailBasic@web163804.mail.gq1.yahoo.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389922759 news.xs4all.nl 2876 [2001:888:2000:d::a6]:33968 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64131 On 2014-01-17 11:14, Chris Angelico wrote: > UTF-8 specifies the byte order > as part of the protocol, so you don't need to mark it. You don't need to mark it when writing, but some idiots use it anyway. If you're sniffing a file for purposes of reading, you need to look for it and remove it from the actual data that gets returned from the file--otherwise, your data can see it as corruption. I end up with lots of CSV files from customers who have polluted it with Notepad or had Excel insert some UTF-8 BOM when exporting. This means my first column-name gets the BOM prefixed onto it when the file is passed to csv.DictReader, grr. -tkc