German umlaut in a string.

Lukas Kasprowicz nospam at maniacxs.de
Tue Aug 12 14:17:10 EDT 2003


Hi Folks,

I have a string filled with much text converted from a tuple.

when I try to do someting like this:

        exclusion = re.sub("\\xf6", "%F6", exclusion) # ö
        exclusion = re.sub("\\xfc", "%FC", exclusion) # ü
        exclusion = re.sub("\\xe4", "%E4", exclusion) # ä 
        exclusion = re.sub("\\xdf", "%DF", exclusion) # ß 

it takes no effect at the string.

things like:

        exclusion = re.sub(',', '', exclusion)
        exclusion = re.sub('\(', '', exclusion)
        exclusion = re.sub('\)', '', exclusion)
        exclusion = re.sub("'", "", exclusion)
        exclusion = re.sub(" ", "+%2D", exclusion)
work fine.

when i write the sting in a python console into a variable like:

        >>> test = "some\\xf6thing"
        >>> print re.sub("\\xf6", "%F6", test)
            some%F6thing

I get the correct output.

Why do I can not do a substitute on "\\xf6" or simmilar, but on other I can
do it (like "\(")

I tried with unicode() converting to I think it was from latin-1 to utf-8
and back. with the python console it worked but not with the string that
was converted from tuple before.


greetz Lukas
-- 
---------------------------------------------------------
Das einzige Mittel gegen Aberglauben ist Wissenschaft.
(Henry Thomas Buckle)




More information about the Python-list mailing list