Strange problems with encoding
Michael Hudson
mwh at python.net
Thu Nov 6 08:39:25 EST 2003
"Sebastian Meyer" <s.meyer at technology-network.de> writes:
> Hi newsgroup,
>
> i am trying to replace german special characters in strings like
> str = re.sub('ö', 'oe', str)
1) str is the name of a builtin -- often a bad idea to use that as a
variable name.
2) I presume `str' is a unicode string? Try writing the literal as
u'ö' instead (and adding the appropriate coding cookie to your
source file if using Python 2.3). Or I guess you could write it
u'\N{LATIN SMALL LETTER O WITH DIAERESIS}'
Cheers,
mwh
--
Usenet is like a herd of performing elephants with diarrhea --
massive, difficult to redirect, awe-inspiring, entertaining, and
a source of mind-boggling amounts of excrement when you least
expect it. -- spaf (1992)
More information about the Python-list
mailing list