Python 3.3 adds the casefold
method to the str type, but in 2.x I don't have anything. What's the best way to work around this?
Approach No 1: Python String lower() Method The lower() method converts all the characters in a string to the lowercase, making it easier to compare two strings.
Class names and constants are written in uppercase. We can ignore case in Python using the . upper() and . lower() methods.
Check out py2casefold.
>>> from py2casefold import casefold
>>> print casefold(u"tschüß")
tschüss
>>> casefold(u"ΣίσυφοςfiÆ") == casefold(u"ΣΊΣΥΦΟσFIæ") == u"σίσυφοσfiæ"
True
There is a thread here which covers some of the issues (but may not resolve all), you can judge whether it is suitable for what you need. If this is no good then there are some useful tips for implementing case folding on the W3C site here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With