Take the 2-minute tour ×  I'm reading and parsing an Amazon XML
file and while the XML file shows a ' , when I try to print it I
get the following error:  'ascii' codec can't encode character
u'\u2019' in position 16: ordinal not in range(128)   From what
I've read online thus far, the error is coming from the fact
that the XML file is in UTF-8, but Python wants to handle it as
an ASCII encoded character. Is there a simple way to make the
error go away and have my program print the XML as it reads?
share|improve this question I was just coming to SO to post this
question. Is there an easy way to sanitize a string for
unicode()? –  Rosarch Jul 11 '10 at 19:02 Please check also this
answer to a related question: “Python UnicodeDecodeError - Am I
misunderstanding encode?” –  tzot Jul 11 '10 at 22:39  3 Answers
3  up vote 77 down vote accepted  Likely, your problem is that
you parsed it okay, and now you're trying to print the contents
of the XML and you can't because theres some foreign Unicode
characters. Try