Jens Müller wrote: > I try to decode a string,e.g. > u'M\xfcnchen, pronounced [\u02c8m\u028fn\xe7\u0259n]'.decode('cp1252', > 'ignore') > but even thoug I use errors='ignore' > I get UnicodeEncodeError: 'charmap' codec can't encode character u'\u02c8' > in position 21: character maps to <undefined> > > How come?
To convert unicode into str you have to *encode()* it. u"...".decode(...) will implicitly convert to ASCII first, i. e. is equivalent to u"...".encode("ascii").decode(...) Hence the error message ...codec can't encode character u'\u02c8'... Peter -- http://mail.python.org/mailman/listinfo/python-list