Reputation: 2752
I have two strings encoded in Unicode. I need to check if they are same. For me, there is no distinction between lowercase and uppercase letters. For ascii strings, the simplest way is to convert both the strings to uppercase and then compare. However in Unicode, this is not possible. What is the best way to do caseless comparison without filtering out the non-ascii characters? for ex: str1 : u'cat \xe0 1234' str2 : u'CAT \xe0 1234'
Upvotes: 0
Views: 162
Reputation: 18978
You can do the same in unicode if you had tried.
>>> u'cat \xe0 1234'.upper() == u'CAT \xc0 1234'.upper()
True
>>> u'\u0431'.upper() == u'\u0411'.upper()
True
Upvotes: 2