How can German sharp s match a caseless search key?

casefold folds characters for caseless comparison and can change the length of the string.

Python example and interpretation

Straße and STRASSE fold to the same key. Keep a position mapping for highlights because one sharp s expands to two characters.

['Straße'.casefold(),'Straße'.casefold()=='STRASSE'.casefold()]

Result ['strasse', True]

中文

怎样让德语词形在无大小写检索中匹配?

casefold 为无大小写比较折叠字符,转换可能改变字符串长度。

Python 算例与适用条件

Straße 与 STRASSE 折叠后相同。不要把折叠串的位置直接当作原文高亮位置,ß 会展开为两个字符。

['Straße'.casefold(),'Straße'.casefold()=='STRASSE'.casefold()]

结果 ['strasse', True]

References / 参考来源

Keep reading / 继续阅读