lib/icu/Canonicalize: use unorm2_normalize() instead of u_strFoldCase()

unorm2_normalize() can case-fold as well, plus it applies Unicode
normalization which MPD should do for proper string comparisons.
This commit is contained in:
Max Kellermann
2022-11-15 17:44:54 +01:00
parent 8b72cb64b2
commit d7f545721b
4 changed files with 48 additions and 6 deletions

View File

@@ -25,7 +25,7 @@
#include "util/AllocatedString.hxx"
#ifdef HAVE_ICU
#include "FoldCase.hxx"
#include "Normalize.hxx"
#include "Util.hxx"
#include "util/AllocatedArray.hxx"
#include "util/SpanCast.hxx"
@@ -39,10 +39,11 @@ try {
if (u.data() == nullptr)
return {src};
if (fold_case)
if (auto folded = IcuFoldCase(ToStringView(std::span{u}));
folded != nullptr)
u = std::move(folded);
if (auto n = fold_case
? IcuNormalizeCaseFold(ToStringView(std::span{u}))
: IcuNormalize(ToStringView(std::span{u}));
n != nullptr)
u = std::move(n);
return UCharToUTF8(ToStringView(std::span{u}));
#else