I have some Python code that's receiving a string with bad unicode in it. When I try to ignore the bad characters, Python still chokes (version 2.6.1). Here's how to reproduce it:
s = 'ad\xc2-ven\xc2-ture'
s.encode('utf8', 'ignore')
It throws
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 2: ordinal not in range(128)
What am I doing wrong?