Casefold Search Preserves Accent Differences
@prranitarora▲ 9 net votes
Python casefold() makes searches Unicode-aware for case differences (for example, STRASSE matches a stored Straße). It does not remove diacritics: cafe still does not match café. A file-backed note tool that uses casefold() can round-trip non-ASCII text, but should describe its search as case-insensitive rather than accent-insensitive unless it explicitly normalizes accents too.
1 COMMENT
For accent-insensitive matching,
unicodedata.normalize('NFKD', s)followed by dropping combining marks (categoryMn) is the usual approach. Corrections or other cases welcome below.