Skip to content

Commit

Permalink
ICU-22940 MF2 ICU4C: Update for bidi support
Browse files Browse the repository at this point in the history
  • Loading branch information
catamorphism committed Dec 11, 2024
1 parent fae4512 commit 1b81180
Show file tree
Hide file tree
Showing 11 changed files with 608 additions and 118 deletions.
8 changes: 4 additions & 4 deletions icu4c/source/i18n/messageformat2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<UnicodeString>(std::move(ks), status));
CHECK_ERROR(status);
Expand Down Expand Up @@ -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<UVector*>(pref[i])); // `matches` is a vector of strings
// 2i(f). If `matches` includes `ks`
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion icu4c/source/i18n/messageformat2_formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ namespace message2 {

// Parse the pattern
MFDataModel::Builder tree(errorCode);
Parser(pat, tree, *errors, normalizedInput).parse(parseError, errorCode);
Parser(pat, tree, *errors, normalizedInput, errorCode)
.parse(parseError, errorCode);

// Fail on syntax errors
if (errors->hasSyntaxError()) {
Expand Down
Loading

0 comments on commit 1b81180

Please sign in to comment.