UnicodeError with OCR Text

Paradox JoeyTaj at netzero.com
Fri May 23 13:09:06 EDT 2003


I am extracting OCR data from SQL Server Text field through ADO and
putting it into a string called fileContent. For some reason it thinks
that every record is a UNICODE string which it is not. For most
records the following line of code will work to get it back to normal
thinking but eventually it will throw a unicode error on one of the
records.

fullText = fullText + fileContent.encode('ascii') + '\n'
UnicodeError: ASCII encoding error: ordinal not in range(128)

I think I isolated it to the degree character "º" HEX is BA, ASCII is
186.

The fileContent will not even print to the output screen. But what is
strange is this code

test = '125º'
print test # This prints well enough
test = test.encode('ascii') #This throws a UnicodeError exception.

Any workarounds to this problem would be appreciated. 

                                   Thanks Joey




More information about the Python-list mailing list