diff --git a/icu4c/source/i18n/messageformat2.cpp b/icu4c/source/i18n/messageformat2.cpp index 8e8675f741a3..fdc98752262d 100644 --- a/icu4c/source/i18n/messageformat2.cpp +++ b/icu4c/source/i18n/messageformat2.cpp @@ -469,8 +469,8 @@ void MessageFormatter::resolvePreferences(MessageContext& context, UVector& res, if (!key.isWildcard()) { // 2ii(b)(a) Assert that key is a literal. // (Not needed) - // 2ii(b)(b) Let `ks` be the resolved value of `key`. - ks = key.asLiteral().unquoted(); + // 2ii(b)(b) Let `ks` be the resolved value of `key` in Unicode Normalization Form C. + ks = normalizeNFC(key.asLiteral().unquoted()); // 2ii(b)(c) Append `ks` as the last element of the list `keys`. ksP.adoptInstead(create(std::move(ks), status)); CHECK_ERROR(status); @@ -531,7 +531,7 @@ void MessageFormatter::filterVariants(const UVector& pref, UVector& vars, UError // 2i(c). Assert that `key` is a literal. // (Not needed) // 2i(d). Let `ks` be the resolved value of `key`. - UnicodeString ks = key.asLiteral().unquoted(); + UnicodeString ks = normalizeNFC(key.asLiteral().unquoted()); // 2i(e). Let `matches` be the list of strings at index `i` of `pref`. const UVector& matches = *(static_cast(pref[i])); // `matches` is a vector of strings // 2i(f). If `matches` includes `ks` @@ -593,7 +593,7 @@ void MessageFormatter::sortVariants(const UVector& pref, UVector& vars, UErrorCo // 5iii(c)(a). Assert that `key` is a literal. // (Not needed) // 5iii(c)(b). Let `ks` be the resolved value of `key`. - UnicodeString ks = key.asLiteral().unquoted(); + UnicodeString ks = normalizeNFC(key.asLiteral().unquoted()); // 5iii(c)(c) Let matchpref be the integer position of ks in `matches`. matchpref = vectorFind(matches, ks); U_ASSERT(matchpref >= 0);