Case-insensitive string equality

Chris Angelico rosuav at gmail.com
Sun Sep 3 08:07:23 EDT 2017


On Sun, Sep 3, 2017 at 5:17 PM, Stephan Houben
<stephanh42 at gmail.com.invalid> wrote:
> Generally speaking, the more you learn about case normalization,
> the more attractive case sensitivity looks ;-)

Absolutely agreed. My general recommendation is to have two vastly
different concepts: "equality matching" and "searching". Equality is
case sensitive and strict; NFC/NFD normalization is about all you can
do. Searching, on the other hand, can be case insensitive, do
NFKC/NFKD normalization, and can even (in many contexts) strip off
diacritical marks altogether, allowing people to search for "resume"
and find "résumé", or to search for "muller" and find "Müller". There
can be a whole swathe of other transformations done in search
normalization too (collapse whitespace, fold punctuation into a few
types, etc), though of course you need to be aware of context. But IMO
it's far safer to NOT define things in terms of "equality".

ChrisA



More information about the Python-list mailing list