how to turn characters in wrong codec into space in python?

80 views Asked by At

I need to read data from an external source, which is from MS.

As you know, MS likes to embed binary to simple text, so sometimes I run into trouble when I encounter such issue:

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 1833: ordinal not in range(128)

So my goal is, instead of this error, I want the text to be output to stdout anyway, but with all these wrong characters turned into white space.

Any idea how to do this? I hope it's not gonna be catch exception and a for loop to manually change it.

0

There are 0 answers