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


Groups > comp.lang.python > #33462

Re: latin1 and cp1252 inconsistent?

References <f063ebaf-89ee-4558-a762-0241efa39dcc@googlegroups.com> <pan.2012.11.17.00.33.13.539000@nowhere.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2012-11-16 18:08 -0700
Subject Re: latin1 and cp1252 inconsistent?
Newsgroups comp.lang.python
Message-ID <mailman.3768.1353114549.27098.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Nov 16, 2012 at 5:33 PM, Nobody <nobody@nowhere.com> 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 == "cp1252a" else None)
>>> b'\x81\x8d\x8f\x90\x9d'.decode('cp1252a')
'♕♖♗♘♙'

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

latin1 and cp1252 inconsistent? buck@yelp.com - 2012-11-16 13:44 -0800
  Re: latin1 and cp1252 inconsistent? Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-16 15:33 -0700
    Re: latin1 and cp1252 inconsistent? buck@yelp.com - 2012-11-16 15:27 -0800
      Re: latin1 and cp1252 inconsistent? Dave Angel <d@davea.name> - 2012-11-16 19:05 -0500
      Re: latin1 and cp1252 inconsistent? Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-16 17:20 -0700
      Re: latin1 and cp1252 inconsistent? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-11-18 01:48 -0500
    Re: latin1 and cp1252 inconsistent? buck@yelp.com - 2012-11-16 15:27 -0800
  Re: latin1 and cp1252 inconsistent? Nobody <nobody@nowhere.com> - 2012-11-17 00:33 +0000
    Re: latin1 and cp1252 inconsistent? Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-16 18:08 -0700
    Re: latin1 and cp1252 inconsistent? buck@yelp.com - 2012-11-17 08:56 -0800
      Re: latin1 and cp1252 inconsistent? Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-17 11:08 -0700
      Re: latin1 and cp1252 inconsistent? Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-17 11:13 -0700
      Re: latin1 and cp1252 inconsistent? Nobody <nobody@nowhere.com> - 2012-11-17 19:15 +0000

csiph-web