Newbie question about text encoding

Mark Lawrence breamoreboy at yahoo.co.uk
Sat Mar 7 12:02:35 EST 2015


On 07/03/2015 16:48, Marko Rauhamaa wrote:
> Mark Lawrence <breamoreboy at yahoo.co.uk>:
>
>> On 07/03/2015 16:25, Marko Rauhamaa wrote:
>>> Here's an example:
>>>
>>>      b = b'\x80'
>>>
>>> Yes, it generates an exception. IOW, UTF-8 is not a bijective mapping
>>> from str objects to bytes objects.
>>
>> Python 2 might, Python 3 doesn't.
>
>     Python 3.3.2 (default, Dec  4 2014, 12:49:00)
>     [GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux
>     Type "help", "copyright", "credits" or "license" for more information.
>     >>> b'\x80'.decode('utf-8')
>     Traceback (most recent call last):
>       File "<stdin>", line 1, in <module>
>     UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0:
>     invalid start byte
>
>
> Marko
>

It would clearly help if you were to type in the correct UK English accent.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list