Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '16,': 0.03; 'explicitly': 0.04; 'method.': 0.05; 'none)': 0.07; 'codecs': 0.09; 'codec': 0.16; 'equivalents': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'import': 0.21; 'modifying': 0.22; 'parse': 0.22; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'convert': 0.29; "skip:' 10": 0.30; 'e.g.': 0.30; 'fri,': 0.30; 'received:209.85.215.46': 0.30; 'skip:b 40': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'nov': 0.35; 'pm,': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'received:209': 0.37; 'subject:: ': 0.38; 'skip:l 20': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'taking': 0.65; 'step,': 0.84; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=cWJSDyJOGxpz4VWNTSsFQGKwH2tUQ/LU0Htq8XSC7qY=; b=VSdHHv6LW+3UVusoYYdgHhYMr0XNhDZeoIrk5w/sukCQvK0oIzf2G7c/Yaf2LQgDbZ +Xthclg7aeBRLkQWFnZcNG8QVyc0UKGEOPQdtcdFMkbxnbqBUU5ZhBJxsi8aXCcKRBFp yh5xrhJfwWyiXRJVIqfLmJsRdEEzdgXr9z2QDPNJZWiW6m3M6+QR8kfWXuA9H2ljwi9/ WiG5hP9kO5RuRZ6fbSFFTI2ylBsWU6aHSfCahkJL4WIHXnWoirj+MFj2Yvj4DpE6hLtG CPsrlJlEYahsNuN8YK74gFLr92b6o18bJwbQziQakGIdncR3Po4vwgT3Q5wNaBNFQrot POaw== MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Fri, 16 Nov 2012 18:08:36 -0700 Subject: Re: latin1 and cp1252 inconsistent? To: Python Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353114549 news.xs4all.nl 6857 [2001:888:2000:d::a6]:37411 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33462 On Fri, Nov 16, 2012 at 5:33 PM, Nobody wrote: > If you need to support either, you can parse it as ISO-8859-1 then > explicitly convert C1 codes to their Windows-1252 equivalents as a > post-processing step, e.g. using the .translate() method. Or just create a custom codec by taking the one in Lib/encodings/cp1252.py and modifying it slightly. >>> import codecs >>> import cp1252a >>> codecs.register(lambda n: cp1252a.getregentry() if n =3D=3D "cp1252a" e= lse None) >>> b'\x81\x8d\x8f\x90\x9d'.decode('cp1252a') '=E2=99=95=E2=99=96=E2=99=97=E2=99=98=E2=99=99'