[Tutor] Working with Umlauts

Tom Churm churmtom@hotmail.com
Fri Jan 17 16:23:05 2003


> 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?

oops...sorry about that...i get it from COM from Lotus Notes (yech!).

i left the script at work unfortunately, but i think the snippet is like
sess = (make Notes Session)
sess.GetSessionUserName

..somethin' like that..

our sys admin for Lotus says that he's not sure if all user names in Lotus
are in unicode, so i gotta make sure and convert them, especially since i'm
then later accessing a different text file (not part of Lotus but placed on
our network) based on the user's name but with the umlauts replaced.

something, i gotta replace those umlauts, and there's gotta be a way..

tom
----- 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
>