Python strings outside the 128 range

Fredrik Lundh fredrik at pythonware.com
Thu Jul 13 06:42:51 EDT 2006


Sébastien Boisgérault wrote:

> Could anyone explain me how the python string "é" is mapped to
> the binary code "\xe9" in my python interpreter ?

in the iso-8859-1 character set, the character é is represented by the code
0xE9 (233 in decimal).  there's no mapping going on here; there's only one
character in the string.  how it appears on your screen depends on how you
print it, and what encoding your terminal is using.

>>> s = "é"
>>> len(s)
1
>>> ord(s)
233
>>> hex(ord(s))
'0xe9'
>>> s
'\xe9'
>>> print repr(s)
'\xe9'
>>> print s
é
>>> print chr(233)
é

</F> 






More information about the Python-list mailing list