utf - string translation

Fredrik Lundh fredrik at pythonware.com
Wed Nov 22 13:51:39 EST 2006


hg wrote:

> We noticed that len('à') != len('a')

sounds odd.

 >>> len('à') == len('a')
True

are you perhaps using an UTF-8 editor?

to keep your sanity, no matter what editor you're using, I recommend 
adding a coding directive to the source file, and using *only* Unicode 
string literals for non-ASCII text.

or in other words, put this at the top of your file (where "utf-8" is 
whatever your editor/system is using):

    # -*- coding: utf-8 -*-

and use

    u'<text>'

for all non-ASCII literals.

</F>




More information about the Python-list mailing list