[Python-Dev] Python3 "complexity"

Ethan Furman ethan at stoneleaf.us
Thu Jan 9 23:08:57 CET 2014


On 01/09/2014 02:00 PM, Chris Barker wrote:
> On Thu, Jan 9, 2014 at 1:45 PM, Antoine Pitrou wrote:
>> Chris Barker wrote:
>>>
>>> latin-1 guaranteed to work with any binary data, and round-trip accurately?
>>
>> Yes, it is.

>>> and will surrogateescape work for arbitrary binary data?
>>
>> Yes, it will.

> Then maybe this is really a documentation issue, after all.
>
> I know I learned something.

If latin1 is used to convert binary to text, how convoluted is it to then take chunks of that text and convert to int, 
or some other variety of unicode?

For example:  b'\x01\x00\xd1\x80\xd1\83\xd0\x80'

If that were decoded using latin1 how would I then get the first two bytes to the integer 256 and the last six bytes to 
their Cyrillic meaning?  (Apologies for not testing myself, short on time.)

--
~Ethan~


More information about the Python-Dev mailing list