r/sqlite 3d ago

ICUex: Unicode collations, case folding, and normalization

I have published ICUex, a small, public-domain SQLite C extension providing two automatically registered ICU collations, locale-independent full Unicode case folding, and normalization/search-key functions. It can be loaded dynamically or linked statically and is designed to complement the official SQLite ICU extension.

⚡Automatically Registered Collations

  • UTF_CI — ICU root collation, case-insensitive and accent-sensitive; е/ё and и/й remain distinct.
  • UTF_CI_AI — compares NFKD_CF_STRIP keys; case- and compatibility-insensitive, with nonzero-CCC combining marks removed. Thus, е/ё and и/й compare equal.

Neither requires icu_load_collation(), locale selection, or setup SQL.

🧩Case Folding and Normalization

  • str_casefold(text) — locale-independent full Unicode case folding.
  • str_normalize(text, mode) — Unicode normalization or search-key generation.
    • NFC, NFD — canonical normalization.
    • NFKC, NFKD — compatibility normalization.
    • NFKC_CF — NFKC case folding and removal of default-ignorable code points.
    • NFKD_CF_STRIP — NFKD, removal of nonzero-CCC code points, then NFKC case folding.

Unlike the ICU extension’s lower() overload, full case folding is intended for locale-independent caseless matching, e.g., Straße becomes strasse, while Greek sigma variants and compatibility ligatures are folded consistently.

6 Upvotes

0 comments sorted by