Skip to content

Commit

Permalink
Set normalization in CPP Collation (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
sven-oly authored Mar 8, 2024
1 parent 33c9564 commit 1713273
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions executors/cpp/coll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,15 @@ const string test_collator(json_object *json_in) {
char uni_rules_out[1000] = "";
int32_t rule_chars_out = uni_rules.extract(uni_rules_out, 1000, nullptr, status);

rb_coll = new RuleBasedCollator(uni_rules, status);
// Make sure normalization is consistent
rb_coll = new RuleBasedCollator(uni_rules, UCOL_ON, status);
if (U_FAILURE(status)) {
test_result = error_message.c_str();
// TODO: report the error in creating the instance
cout << "# Error in making RuleBasedCollator: " << label_string << " : " << test_result << endl;

json_object_object_add(return_json,
"error", json_object_new_string("creat rule based collator"));
"error", json_object_new_string("creat rule based collator"));
no_error = false;
}

Expand Down Expand Up @@ -178,6 +179,16 @@ const string test_collator(json_object *json_in) {
cout << "# Error in createInstance: " << label_string << " : " << test_result << endl;
}

// Make sure normalization is consistent
uni_coll->setAttribute(UCOL_NORMALIZATION_MODE, UCOL_ON, status);
if (U_FAILURE(status)) {
test_result = error_message.c_str();
json_object_object_add(return_json,
"error", json_object_new_string("error setting normalization to UCOL_ON"));
no_error = false;
cout << "# Error in setAttribute: " << label_string << " : " << test_result << endl;
}

if (strength_obj) {
uni_coll->setStrength(strength_type);
}
Expand Down

0 comments on commit 1713273

Please sign in to comment.