> -----Original Message-----
> From: Python-Dev [mailto:python-dev-
> bounces+kristjan=ccpgames....@python.org] On Behalf Of Antoine Pitrou
> Sent: 9. janúar 2014 13:18
> To: python-dev@python.org
> Subject: Re: [Python-Dev] Python3 "complexity"
> 
> On Thu, 9 Jan 2014 12:55:35 +0000
> Kristján Valur Jónsson <krist...@ccpgames.com> wrote:
> > > If you don't "care" about the encoding, why don't you use latin1?
> > > Things will roundtrip fine and work as well as under Python 2.
> >
> > Because latin1 does not define all code points, giving you errors there.
> 
> >>> b = bytes(range(256))
> >>> b.decode('latin1')
> '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12
> \x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-
> ./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijkl
> mnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x
> 8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9
> c\x9d\x9e\x9f\xa0¡¢£¤¥¦§¨©ª«¬\xad®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎ
> ÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'

You are right.  I'm talking about "cp1252" which is the windows version thereof:
>>> s = ''.join(chr(i) for i in range(256))
>>> s.decode('cp1252')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\encodings\cp1252.py", line 15, in decode
    return codecs.charmap_decode(input,errors,decoding_table)
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 129: 
character maps to <undefined>

This definition is funny, because according to Wikipedia, it is a "superset" of 
8869-1 ( latin1)
See http://en.wikipedia.org/wiki/Cp1252
Also, see 
http://en.wikipedia.org/wiki/Latin1 

There is confusion there.  The iso8859-1 does in fact not define the control 
codes in range 128 to 158, whereas the
Unicode page Latin 1 does.  
Strictly speaking, then, a Latin1 (or more specifically, ISO8859-1) decoder 
should error on these characters.
the 'Latin1' codec therefore is not a true 8859-1 codec.

K
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to