1

On PG 13 documentation, there are several examples of ICU collations for specialized purposes. It is also mentioned that ICU locales exist that allow creating collations to ignore accents, and that they can be found on https://github.com/unicode-org/cldr/blob/master/common/bcp47/collation.xml

However, after reading that document, I am still unclear on what is the locale I should use to create an ICU collation for accent insensitive comparisons in Spanish.

What is the name of such an ICU locale? Is there any list of ICU Spanish collations?

1 Answer 1

3

This would be a case sensitice, but accent insensitive locale for Spain that works with recent versions of ICU:

CREATE COLLATION spanish_noaccent (
   PROVIDER = 'icu',
   LOCALE = 'es-ES-u-ks-level1-kc',
   DETERMINISTIC = FALSE
);

SELECT 'Olé' = 'Ole' COLLATE spanish_noaccent;

 ?column? 
══════════
 t
(1 row)

SELECT 'Olé' = 'ole' COLLATE spanish_noaccent;

 ?column? 
══════════
 f
(1 row)

ks-level1 means "case and accent insensitive", and kc adds case sensitivity.

See my blog post for more.

5
  • That blog post should be referenced from the docs. That would save people a lot of time. Thanks a lot.
    – ARX
    Sep 13, 2021 at 3:35
  • I could not find in your blog post the definitions of variant subtags kf and kr, which are used in the examples of the docs. Do you know their meaning?
    – ARX
    Sep 13, 2021 at 3:58
  • You can look that up in unicode.org/reports/tr35/tr35-13.html Nov 11, 2021 at 8:20
  • am i missing something. you posted the same query, one return true, one return false?
    – jian
    Apr 13 at 3:42
  • @jian One of the queries has an ipper case Ole, the other a lower case ole. Apr 15 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.