I am trying to retrieve some data from MySQL and I have problems reading the data. The column datatype is varchar with utf8_general-ci. I tried decoding it but it doesn't work. So, I want to remove those non utf8 characters since I don't need those non utf8 characters.
#This is the line causing the problem:
line: ((123, 'Classical Musicï¼\x8c', 69),)
conn = db.cursor()
conn.execute(sql)
data = conn.fetchall()
for line in data:
for x in line:
print(x)
Error code received
UnicodeEncodeError: 'charmap' codec can't encode character '\x8c' in position 17
I have tried decode('utf-8') but I get another error.
conn = db.cursor()
conn.execute(sql)
data = conn.fetchall()
for line in data:
for x in line:
print(x[1].decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'
C3 AF C2, which probably is the first half ofC3 AF C2 BB C2 BF, an utf-8 bom encoded with utf8. - sisve