[Tutor] Working with Umlauts

Tom Churm churmtom@hotmail.com
Fri Jan 17 16:40:02 2003


i just tried this in IDLE and it worked:

>>> import string
>>> lastNameOfUser = "töm"
>>> lastNameOfUser = string.replace(lastNameOfUser,"ö","oe")
>>> print lastNameOfUser
toem

so it looks like this is a problem with my PythonWin on ActivePython (here
at home i'm using the python.org python installation).

i'm going to call it quits with ActivePython and install the normal python
distribution at work, and then look for another editor.

thanks for the help!

Tom Churm
churmtom@hotmail.com
----- Original Message -----
From: "Magnus Lycka" <magnus@thinkware.se>
To: "Tom Churm" <churmtom@hotmail.com>; <tutor@python.org>
Sent: Friday, January 17, 2003 9:40 PM
Subject: Re: [Tutor] Working with Umlauts


> At 13:06 2003-01-17 +0100, Tom Churm wrote:
> >>Where does lastNameOfUser come from?
> >this is one of my variables...employee names
> >that--unfortunately!--sometimes contain umlauts
>
> Yes, I understand those parts. I wonder how the string
> data ends up in the variable. By divine intervention or
> what? Do you get it through COM fro ma Windows application,
> or do you get it via ODBC from Access or what? Read from
> a text file? The big issue is: Are you sure it is of type
> string? Or is it a Unicode object? What does
>    print type(lastNameOfUser)
> say?
>
> >>you perchance working in IDLE? Face it: IDLE doesn't work!
> >i'm using PythonWin, ActivePython build 2.1.212,
> >and no, this doesn't work so great sometimes either.
>
>
> PythinWin works like a charm for me except when I backspace on
> non-ASCII characters. Then I sometimes get some odd character
> that I need to remove as well.
>
> When I try:
>
> lastNameOfUser = """string.replace(lastNameOfUser,"ä","ae")
> lastNameOfUser = string.replace(lastNameOfUser,"ö","oe")
> lastNameOfUser = string.replace(lastNameOfUser,"ü","ue")
> lastNameOfUser = string.replace(lastNameOfUser,"ß","ss")
> lastNameOfUser = string.replace(lastNameOfUser,"Ä","Ae")
> lastNameOfUser = string.replace(lastNameOfUser,"Ö","Oe")
> lastNameOfUser = string.replace(lastNameOfUser,"Ü","Ue")"""
>
> lastNameOfUser = string.replace(lastNameOfUser,"ä","ae")
> lastNameOfUser = string.replace(lastNameOfUser,"ö","oe")
> lastNameOfUser = string.replace(lastNameOfUser,"ü","ue")
> lastNameOfUser = string.replace(lastNameOfUser,"ß","ss")
> lastNameOfUser = string.replace(lastNameOfUser,"Ä","Ae")
> lastNameOfUser = string.replace(lastNameOfUser,"Ö","Oe")
> lastNameOfUser = string.replace(lastNameOfUser,"Ü","Ue")
>
> print lastNameOfUser
>
> in PythonWin I get:
>
> string.replace(lastNameOfUser,"ae","ae")
> lastNameOfUser = string.replace(lastNameOfUser,"oe","oe")
> lastNameOfUser = string.replace(lastNameOfUser,"ue","ue")
> lastNameOfUser = string.replace(lastNameOfUser,"ss","ss")
> lastNameOfUser = string.replace(lastNameOfUser,"Ae","Ae")
> lastNameOfUser = string.replace(lastNameOfUser,"Oe","Oe")
> lastNameOfUser = string.replace(lastNameOfUser,"Ue","Ue")
>
> Just as expected.
>
>
> --
> Magnus Lycka, Thinkware AB
> Alvans vag 99, SE-907 50 UMEA, SWEDEN
> phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
> http://www.thinkware.se/  mailto:magnus@thinkware.se
>