Performance issues
The method you choose will actually work in most settings. If you are looking for something more effective, you cannot find it. The reason is that capital letters and lowercase letters are stored with different encodings. Thus, it is not as if there is some kind of capitalization field for a character object that can be ignored when comparing characters in strings. Fortunately, the bit difference between capital and lower case is very small, and therefore conversions are simple and effective. See this SO post for background on this:
How do uppercase and lowercase letters differ in only one bit?
Accuracy
In most settings, the method you have will work exactly. But, if you encounter characters such as Greek letters with uppercase or lowercase letters, this may fail. To do this, you will be better off working with the normalize_string() function (for more details see docs ) with the casefold option:
normalize_string("ad", casefold=true)
See this SO post in the Python context for a discussion of related issues and therefore no need to repeat:
How to make case-insensitive string comparisons in Python?
Since he talks about the main problems with utf encoding, it applies to both Julia and Python.
See also Julia Github's discussion for additional background and specific examples of places where lowercase() might fail:
https://github.com/JuliaLang/julia/issues/7848
source share