Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Ulrich Eckhardt Newsgroups: comp.lang.python Subject: codec for UTF-8 with BOM Followup-To: comp.lang.python Date: Mon, 02 May 2011 10:34:11 +0200 Lines: 27 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: news.uni-berlin.de yeeB+q7ImMpbKfkn+oyA5wJZC9LTk+8qv+Ga/cxY2kmw== X-Orig-Path: satorlaser.homedns.org!not-for-mail User-Agent: KNode/4.4.7 Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4463 Hi! I want to write a file starting with the BOM and using UTF-8, and stumbled across some problems: 1. I would have expected one of the codecs to be 'UTF-8 with BOM' or something like that, but I can't find the correct name. Also, I can't find a way to get a list of the supported codecs at all, which strikes me as odd. 2. I couldn't find a way to write the BOM either. Writing codecs.BOM doesn't work, as it is an already encoded byte string. Of course, I can write u'\ufeff', but I'd rather avoid such magic numbers in my code. 3. The docs mention encodings.utf_8_sig, available since 2.5, but I can't locate that thing there either. What's going on here? What would you do? Uli -- Domino Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932