Strange problems with encoding

Sebastian Meyer s.meyer at technology-network.de
Thu Nov 6 09:10:49 EST 2003


On Thu, 06 Nov 2003 13:39:25 +0000, Michael Hudson wrote:

> "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.

it was only the example name for the variable, be sure that dont
use any builtins as variable names
maybe not a good example ... thanks for the hint

> 
> 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}'

i ll try and report back...

> 
> Cheers,
> mwh





More information about the Python-list mailing list