Python 2.4 vs 2.5 - Unicode error

Gaurav Veda vedagaurav at gmail.com
Fri Jan 23 04:14:19 CET 2009


On Jan 21, 7:08 pm, John Machin <sjmac... at lexicon.net> wrote:
>
> To replace non-ASCII characters in a UTF-8-encoded string by spaces:
> | >>> u8 = ' and 25\xc2\xb0F'
> | >>> u = u8.decode('utf8')
> | >>> ''.join([chr(ord(c)) if c <= u'\x7f' else ' ' for c in u])
> | ' and 25 F'

Thanks John for your reply. This is what I needed.

Cheers,
Gaurav



More information about the Python-list mailing list