{
char *name;
char *value;
- UColAttribute uattr = -1;
- UColAttributeValue uvalue = -1;
+ UColAttribute uattr;
+ UColAttributeValue uvalue;
UErrorCode status;
status = U_ZERO_ERROR;
uattr = UCOL_NORMALIZATION_MODE;
else if (strcmp(name, "colnumeric") == 0)
uattr = UCOL_NUMERIC_COLLATION;
- /* ignore if unknown */
+ else
+ /* ignore if unknown */
+ continue;
if (strcmp(value, "primary") == 0)
uvalue = UCOL_PRIMARY;
else
status = U_ILLEGAL_ARGUMENT_ERROR;
- if (uattr != -1 && uvalue != -1)
+ if (status == U_ZERO_ERROR)
ucol_setAttribute(collator, uattr, uvalue, &status);
/*
drop type textrange_c;
drop type textrange_en_us;
-- test ICU collation customization
+-- test the attributes handled by icu_set_collation_attributes()
CREATE COLLATION testcoll_ignore_accents (provider = icu, locale = '@colStrength=primary;colCaseLevel=yes');
SELECT 'aaá' > 'AAA' COLLATE "und-x-icu", 'aaá' < 'AAA' COLLATE testcoll_ignore_accents;
?column? | ?column?
CREATE COLLATION testcoll_error1 (provider = icu, locale = '@colNumeric=lower');
ERROR: could not open collator for locale "@colNumeric=lower": U_ILLEGAL_ARGUMENT_ERROR
+-- test that attributes not handled by icu_set_collation_attributes()
+-- (handled by ucol_open() directly) also work
+CREATE COLLATION testcoll_de_phonebook (provider = icu, locale = 'de@collation=phonebook');
+SELECT 'Goldmann' < 'Götz' COLLATE "de-x-icu", 'Goldmann' > 'Götz' COLLATE testcoll_de_phonebook;
+ ?column? | ?column?
+----------+----------
+ t | t
+(1 row)
+
-- cleanup
SET client_min_messages TO warning;
DROP SCHEMA collate_tests CASCADE;
-- test ICU collation customization
+-- test the attributes handled by icu_set_collation_attributes()
+
CREATE COLLATION testcoll_ignore_accents (provider = icu, locale = '@colStrength=primary;colCaseLevel=yes');
SELECT 'aaá' > 'AAA' COLLATE "und-x-icu", 'aaá' < 'AAA' COLLATE testcoll_ignore_accents;
CREATE COLLATION testcoll_error1 (provider = icu, locale = '@colNumeric=lower');
+-- test that attributes not handled by icu_set_collation_attributes()
+-- (handled by ucol_open() directly) also work
+CREATE COLLATION testcoll_de_phonebook (provider = icu, locale = 'de@collation=phonebook');
+SELECT 'Goldmann' < 'Götz' COLLATE "de-x-icu", 'Goldmann' > 'Götz' COLLATE testcoll_de_phonebook;
+
-- cleanup
SET client_min_messages TO warning;