serge-sans-paille/frozen

Case-insensitive option?

rael007 opened this issue · 4 comments

Is it possible to provide case-insensitive lookup of frozen::string keys in, say, the frozen::unordered_map?

Case-insensitive equivalence requires knowledge about the charset of the string:

  • it is trivial for ASCII
  • it is doable via simple lookup tables for ISO-8859-X charset family (but need different tables for each -X charset), but already introduce tricky corner cases (e.g. German ß -> SS or turkish dotless i, so case folding and case equivalence already is locale-dependent))
  • it becomes very complex for Unicode (UTF-8) strings, face you with non-reflexive and non-transitive case conversions and you must handle NFC/NFD equivalence and conversions etc. – far too complex for a sinple string class. BTDT.

@rael007 I think that's out of scope for the frozen library, but you can perfectly write a (constexpr) function that takes a frozen::string and returns its tolower version, and use it both for initialization and lookup, modulo the advices of @RokerHRO .

@rael007: Yes, I agree. Proper Unicode handling is far out of scope of both frozen::string and std::string. There are specialized libraries for it (e.g. libiconv), but even with these libraries the user has to know a lot about Unicode and the awkwardness of foreign scripts to use that libraries properly and correctly. It is far more complicated than English-only-speaking people might think. ;-(

ok, closing the issue then.