utf - string translation
hg
hg at nospam.com
Wed Nov 22 14:05:38 EST 2006
Duncan Booth wrote:
> hg <hg at nospam.com> wrote:
>
>>> 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>
>>>
>> Hi,
>>
>> The problem is that:
>>
>> # -*- coding: utf-8 -*-
>> import string
>> print len('a')
>> print len('à')
>>
>> returns 1 then 2
>
> And if you do what was suggested and write:
>
> # -*- coding: utf-8 -*-
> import string
> print len(u'a')
> print len(u'à')
>
> then you get:
>
> 1
> 1
OK,
How would you handle the string.maketrans then ?
hg
More information about the Python-list
mailing list