String methods understanding anything but ASCII?

Magnus Lie Hetland mlh at vier.idi.ntnu.no
Mon Jan 20 15:35:04 EST 2003


In article <3e2b1774$0$49114$e4fe514c at news.xs4all.nl>, Irmen de Jong wrote:
>Magnus Lie Hetland wrote:
>> I just wondered -- is there hope that string methods such as upper()
>> or capitalize() will ever understand anything other than ascii? How
>> about, e.g. iso8859-1 (which does seem to be the default encoding)? As
>> a Scandinavian, I'd love to see 'ø'.upper() == 'Ø', for example.
>
>>>> print unicode('ø','cp1252').upper().encode('cp1252')
>Ø

Ah. I tried to use unicode objects (with 'isp8859-1', though, but
that's not essential) -- I just didn't use the extra argument to the
constructor. (Silly me ;)

Needless to say, I couldn't get it to work...

>You should use the unicode functions to perform operations on
>non-ascii characters.

Indeed. Thanks.

>Irmen

-- 
Magnus Lie Hetland
http://hetland.org




More information about the Python-list mailing list