Unicode characters in btye-strings

Robert Kern robert.kern at gmail.com
Fri Mar 12 16:37:36 CET 2010

On 2010-03-12 06:35 AM, Steven D'Aprano wrote:
> I know this is wrong, but I'm not sure just how wrong it is, or why.
> Using Python 2.x:
>>>> s = "éâÄ"
>>>> print s
> éâÄ
>>>> len(s)
> 6
>>>> list(s)
> ['\xc3', '\xa9', '\xc3', '\xa2', '\xc3', '\x84']
> Can somebody explain what happens when I put non-ASCII characters into a
> non-unicode string? My guess is that the result will depend on the
> current encoding of my terminal.

Exactly right.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

More information about the Python-list mailing list