Skip to content

Commit 1b81180

Browse files
committed
ICU-22940 MF2 ICU4C: Update for bidi support
Per unicode-org/message-format-wg#884
1 parent fae4512 commit 1b81180

11 files changed

+608
-118
lines changed

icu4c/source/i18n/messageformat2.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,8 @@ void MessageFormatter::resolvePreferences(MessageContext& context, UVector& res,
469469
if (!key.isWildcard()) {
470470
// 2ii(b)(a) Assert that key is a literal.
471471
// (Not needed)
472-
// 2ii(b)(b) Let `ks` be the resolved value of `key`.
473-
ks = key.asLiteral().unquoted();
472+
// 2ii(b)(b) Let `ks` be the resolved value of `key` in Unicode Normalization Form C.
473+
ks = normalizeNFC(key.asLiteral().unquoted());
474474
// 2ii(b)(c) Append `ks` as the last element of the list `keys`.
475475
ksP.adoptInstead(create<UnicodeString>(std::move(ks), status));
476476
CHECK_ERROR(status);
@@ -531,7 +531,7 @@ void MessageFormatter::filterVariants(const UVector& pref, UVector& vars, UError
531531
// 2i(c). Assert that `key` is a literal.
532532
// (Not needed)
533533
// 2i(d). Let `ks` be the resolved value of `key`.
534-
UnicodeString ks = key.asLiteral().unquoted();
534+
UnicodeString ks = normalizeNFC(key.asLiteral().unquoted());
535535
// 2i(e). Let `matches` be the list of strings at index `i` of `pref`.
536536
const UVector& matches = *(static_cast<UVector*>(pref[i])); // `matches` is a vector of strings
537537
// 2i(f). If `matches` includes `ks`
@@ -593,7 +593,7 @@ void MessageFormatter::sortVariants(const UVector& pref, UVector& vars, UErrorCo
593593
// 5iii(c)(a). Assert that `key` is a literal.
594594
// (Not needed)
595595
// 5iii(c)(b). Let `ks` be the resolved value of `key`.
596-
UnicodeString ks = key.asLiteral().unquoted();
596+
UnicodeString ks = normalizeNFC(key.asLiteral().unquoted());
597597
// 5iii(c)(c) Let matchpref be the integer position of ks in `matches`.
598598
matchpref = vectorFind(matches, ks);
599599
U_ASSERT(matchpref >= 0);

icu4c/source/i18n/messageformat2_formatter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ namespace message2 {
4545

4646
// Parse the pattern
4747
MFDataModel::Builder tree(errorCode);
48-
Parser(pat, tree, *errors, normalizedInput).parse(parseError, errorCode);
48+
Parser(pat, tree, *errors, normalizedInput, errorCode)
49+
.parse(parseError, errorCode);
4950

5051
// Fail on syntax errors
5152
if (errors->hasSyntaxError()) {

0 commit comments

Comments
 (0)