I have a site that displays user input by decoding it to unicode using utf-8. However, user input can include binary data, which is obviously not always able to be ‘decoded’ by utf-8.
I’m using Python, and I get an error saying:
‘utf8’ codec can’t decode byte 0xbf in position 0: unexpected code byte. You passed in ‘\xbf\xcd…
Is there a standard efficient way to convert those undecodable characters into question marks?
It would be most helpful if the answer uses Python.
Try:
See here for reference