I have a string containing what I guess you'd call a "special" character (o with an umlaut above it) and it's throwing off a DBF library I am using (Ethan Furman's Python DBF library https://pypi.python.org/pypi/dbf retrieve_character()
function, error on last line of the function is 'ascii' codec can't decode byte 0xf6 in position 6: ordinal not in range(128)
).
The code:
def retrieve_character(bytes, fielddef, memo, decoder):
"""
Returns the string in bytes as fielddef[CLASS] or fielddef[EMPTY]
"""
data = bytes.tostring()
if not data.strip():
cls = fielddef[EMPTY]
if cls is NoneType:
return None
return cls(data)
if fielddef[FLAGS] & BINARY:
return data
return fielddef[CLASS](decoder(data)[0]) #error on this line