replace text in unicode string

Svennglenn Danielnord15 at yahoo.se
Sat May 14 04:17:44 EDT 2005


I'm having problems replacing text in a
unicode string.
Here's the code:

# -*- coding: cp1252 -*-

titel = unicode("ä", "iso-8859-1")
print titel
print type(titel)

titel.replace("ä", "a")


When i run this program I get this error:

    titel.replace("ä", "a")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0:
ordinal not in range(128)


How can i replace text in the Unicode string?




More information about the Python-list mailing list