0
votes

I have a problem related to Unicode in this line:

strToCompare =  str(self.modelProxy.data(cellIndex, Qt.DisplayRole).toString()).lower()

The error is:

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 5: ordinal not in range(128)

This is because the data is retrieve from a field in a database which may contain unicode characters. Even though I added the unicode() function to convert to Unicode, the error is still there.

1
Could you post the string? - user1006989
the character is \xe9 which means é. The problem is that I have this problem only on client machine and not mine even we have the same python version (2.6) - nam

1 Answers

0
votes

I've my solution, I just get the string in the model instead of using the function data(). This way I don't have to convert the QVariant into String