Unicode troubles

"Martin v. Löwis" martin at v.loewis.de
Fri Oct 10 18:51:15 EDT 2003


Rodrigo Benenson wrote:

> Sometimes I get len(u"eló") = 3 (the good result) and other times
> len(u"eló") = 4 (wrong result). These seems indiferent of the OS.

You should not use non-ASCII characters in source code, unless you
also use a PEP 263 source encoding. Most likely, the string your
editor displays is not the string you are constructing. Use hexadecimal
or symbolic notation for non-ASCII characters in Python source code.
Available notations are \x, \u, and \N.

Regards,
Martin





More information about the Python-list mailing list