-
In your library, you have Is this the same as a canonical caseless match? I'm writing a program, and I need to handle Unicode, which I currently do transparently as a sequence of bytes in a std::string, but now I actually need to do some comparisons, and your library stands out to me as a lightweight (header-only!) solution. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
No, it's not the same. The Unicode Standard describes canonical caseless match like this:
So it will look like this with the library: bool canonical_caseless_match(std::string_view str1, std::string_view str2)
{
return una::norm::to_nfd_utf8(una::cases::to_casefold_utf8(una::norm::to_nfd_utf8(str1))) ==
una::norm::to_nfd_utf8(una::cases::to_casefold_utf8(una::norm::to_nfd_utf8(str2)));
} Of course the performance of this won't be that great. Technically it's possible to implement it better with views but the problem right now the library doesn't have case folding view (it's planned). So you need to implement it manually with |
Beta Was this translation helpful? Give feedback.
No, it's not the same. The Unicode Standard describes canonical caseless match like this:
So it will look like this with the library:
Of course the performance of this won't be that great. Technically it's possible to implement it better with views but the problem right now the library doesn't have c…