Re: replace text in unicode string
- From: "Dan Bishop" <danb_83@xxxxxxxxx>
- Date: 14 May 2005 02:23:55 -0700
Svennglenn wrote:
> 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?
titel = titel.replace(u"ä", "a")
.
- Follow-Ups:
- Re: replace text in unicode string
- From: John Machin
- Re: replace text in unicode string
- References:
- replace text in unicode string
- From: Svennglenn
- replace text in unicode string
- Prev by Date: sockets don't play nice with new style classes :(
- Next by Date: Re: 80 bit precision ?
- Previous by thread: replace text in unicode string
- Next by thread: Re: replace text in unicode string
- Index(es):
Relevant Pages
|
|