Unicode...:Locale(3pm)

🌸 NAME 🌸

Unicode::Collate::Locale β€” Linguistic tailoring for DUCET via Unicode::Collate

okay bestie, this is the Unicode::Collate::Locale(3pm) page from the Perl Programmers Reference Guide, part 1, and we are absolutely getting into DUCET tailoring together πŸ’–


πŸ’« SYNOPSIS πŸ’«

use Unicode::Collate::Locale;

#construct
$Collator = Unicode::Collate::Locale->
    new(locale => $locale_name, %tailoring);

#sort
@sorted = $Collator->sort(@not_sorted);

#compare
$result = $Collator->cmp($a, $b); # returns 1, 0, or -1.

Note: the strings in @not_sorted, $a, and $b are interpreted according to Perl's Unicode support. Peep perlunicode, perluniintro, perlunitut, perlunifaq, utf8. Otherwise you can use preprocess (cf. Unicode::Collate) or you should decode them before.


🧠 DESCRIPTION 🧠

This module provides linguistic tailoring for it, taking advantage of Unicode::Collate.

πŸ› οΈ Constructor πŸ› οΈ

The new method returns a collator object.

A parameter list for the constructor is a hash, which can include a special key locale and its value (case-insensitive) standing for a Unicode base language code (two or three-letter). For example, Unicode::Collate::Locale->new(locale => 'ES') returns a collator tailored for Spanish.

$locale_name may be suffixed with a Unicode script code (four-letter), a Unicode region (territory) code, a Unicode language variant code. These codes are case-insensitive, and separated with _ or -. E.g. en_US for English in USA, az_Cyrl for Azerbaijani in the Cyrillic script, es_ES_traditional for Spanish in Spain (Traditional).

If $locale_name is not available, fallback is selected in the following order:

  1. language with a variant code
  2. language with a script code
  3. language with a region code
  4. language
  5. default

Tailoring tags provided by Unicode::Collate are allowed as long as they are not used for locale support. Esp. the table tag is always untailorable, since it is reserved for DUCET.

However entry is allowed, even if it is used for locale support, to add or override mappings.

E.g. a collator for Spanish, which ignores diacritics and case difference (i.e. level 1), with reversed case ordering and no normalization.

Unicode::Collate::Locale->new(
    level => 1,
    locale => 'es',
    upper_before_lower => 1,
    normalization => undef
)

Overriding a behavior already tailored by locale is disallowed if such a tailoring is passed to new().

Unicode::Collate::Locale->new(
    locale => 'da',
    upper_before_lower => 0, # causes error as reserved by 'da'
)

However change() inherited from Unicode::Collate allows such a tailoring that is reserved by locale. Examples:

new(locale => 'fr_ca')->change(backwards => undef)
new(locale => 'da')->change(upper_before_lower => 0)
new(locale => 'ja')->change(overrideCJK => undef)

🧚 Methods 🧚

Unicode::Collate::Locale is a subclass of Unicode::Collate and methods other than new are inherited from Unicode::Collate.

Here is a list of additional methods:

  • $Collator->getlocale β€” Returns a language code accepted and used actually on collation. If linguistic tailoring is not provided for a language code you passed (intensionally for some languages, or due to the incomplete implementation), this method returns a string 'default' meaning no special tailoring.
  • $Collator->locale_version β€” (Since Unicode::Collate::Locale 0.87) Returns the version number (perhaps /\d\.\d\d/) of the locale, as that of Locale/*.pl.
Note: Locale/*.pl that a collator uses should be identified by a combination of return values from getlocale and locale_version.

🌍 A list of tailorable locales 🌍

here’s the whole roster β€” locale name first, then the description, and don’t skip any, bestie 🫢

  • af β€” Afrikaans
  • ar β€” Arabic
  • as β€” Assamese
  • az β€” Azerbaijani (Azeri)
  • be β€” Belarusian
  • bn β€” Bengali
  • bs β€” Bosnian (tailored as Croatian)
  • bs_Cyrl β€” Bosnian in Cyrillic (tailored as Serbian)
  • ca β€” Catalan
  • cs β€” Czech
  • cu β€” Church Slavic
  • cy β€” Welsh
  • da β€” Danish
  • de__phonebook β€” German (umlaut as 'ae', 'oe', 'ue')
  • de_AT_phonebook β€” Austrian German (umlaut primary greater)
  • dsb β€” Lower Sorbian
  • ee β€” Ewe
  • eo β€” Esperanto
  • es β€” Spanish
  • es__traditional β€” Spanish ('ch' and 'll' as a grapheme)
  • et β€” Estonian
  • fa β€” Persian
  • fi β€” Finnish (v and w are primary equal)
  • fi__phonebook β€” Finnish (v and w as separate characters)
  • fil β€” Filipino
  • fo β€” Faroese
  • fr_CA β€” Canadian French
  • gu β€” Gujarati
  • ha β€” Hausa
  • haw β€” Hawaiian
  • he β€” Hebrew
  • hi β€” Hindi
  • hr β€” Croatian
  • hu β€” Hungarian
  • hy β€” Armenian
  • ig β€” Igbo
  • is β€” Icelandic
  • ja β€” Japanese [1]
  • kk β€” Kazakh
  • kl β€” Kalaallisut
  • kn β€” Kannada
  • ko β€” Korean [2]
  • kok β€” Konkani
  • lkt β€” Lakota
  • ln β€” Lingala
  • lt β€” Lithuanian
  • lv β€” Latvian
  • mk β€” Macedonian
  • ml β€” Malayalam
  • mr β€” Marathi
  • mt β€” Maltese
  • nb β€” Norwegian Bokmal
  • nn β€” Norwegian Nynorsk
  • nso β€” Northern Sotho
  • om β€” Oromo
  • or β€” Oriya
  • pa β€” Punjabi
  • pl β€” Polish
  • ro β€” Romanian
  • sa β€” Sanskrit
  • se β€” Northern Sami
  • si β€” Sinhala
  • si__dictionary β€” Sinhala (U+0DA5 = U+0DA2,0DCA,0DA4)
  • sk β€” Slovak
  • sl β€” Slovenian
  • sq β€” Albanian
  • sr β€” Serbian
  • sr_Latn β€” Serbian in Latin (tailored as Croatian)
  • sv β€” Swedish (v and w are primary equal)
  • sv__reformed β€” Swedish (v and w as separate characters)
  • ta β€” Tamil
  • te β€” Telugu
  • th β€” Thai
  • tn β€” Tswana
  • to β€” Tonga
  • tr β€” Turkish
  • ug_Cyrl β€” Uyghur in Cyrillic
  • uk β€” Ukrainian
  • ur β€” Urdu
  • vi β€” Vietnamese
  • vo β€” Volapu"k
  • wae β€” Walser
  • wo β€” Wolof
  • yo β€” Yoruba
  • zh β€” Chinese
  • zh__big5han β€” Chinese (ideographs: big5 order)
  • zh__gb2312han β€” Chinese (ideographs: GB-2312 order)
  • zh__pinyin β€” Chinese (ideographs: pinyin order) [3]
  • zh__stroke β€” Chinese (ideographs: stroke order) [3]
  • zh__zhuyin β€” Chinese (ideographs: zhuyin order) [3]

Locales according to the default UCA rules include am (Amharic) without [reorder Ethi], bg (Bulgarian) without [reorder Cyrl], chr (Cherokee) without [reorder Cher], de (German), en (English), fr (French), ga (Irish), id (Indonesian), it (Italian), ka (Georgian) without [reorder Geor], mn (Mongolian) without [reorder Cyrl Mong], ms (Malay), nl (Dutch), pt (Portuguese), ru (Russian) without [reorder Cyrl], sw (Swahili), zu (Zulu).

πŸ“ Note

[1] ja: Ideographs are sorted in JIS X 0208 order. Fullwidth and halfwidth forms are identical to their regular form. The difference between hiragana and katakana is at the 4th level, the comparison also requires (variable => 'Non-ignorable'), and then katakana_before_hiragana has no effect.

[2] ko: Plenty of ideographs are sorted by their reading. Such an ideograph is primary (level 1) equal to, and secondary (level 2) greater than, the corresponding hangul syllable.

[3] zh__pinyin, zh__stroke and zh__zhuyin: implemented alt='short', where a smaller number of ideographs are tailored.

🏷️ A list of variant codes and their aliases 🏷️

variant code first, alias after β€” collect them all, bestie ✨

  • dictionary β€” alias: dict
  • phonebook β€” alias: phone, phonebk
  • reformed β€” alias: reform
  • traditional β€” alias: trad
  • big5han β€” alias: big5
  • gb2312han β€” alias: gb2312
  • pinyin
  • stroke
  • zhuyin
Note: 'pinyin' is Han in Latin, 'zhuyin' is Han in Bopomofo.

πŸ› οΈ INSTALL πŸ› οΈ

Installation of Unicode::Collate::Locale requires Collate/Locale.pm, Collate/Locale/*.pm, Collate/CJK/*.pm and Collate/allkeys.txt. On building, Unicode::Collate::Locale doesn't require any of data/*.txt, gendata/*, and mklocale. Tests for Unicode::Collate::Locale are named t/loc_*.t.


part 2 continues below, bestie β€” no cap πŸ’–

😭 CAVEAT 😭

okay bestie, before you go full custom-locale main-character mode, there are two big caveats. they are giving β€œread this before you ship it” energy, and they are lowkey important.

πŸ’… Tailoring is not maximum πŸ’…

Even if a certain letter is tailored, its equivalent would not always be tailored as well as it. For example, even though W is tailored, fullwidth W ("U+FF37"), W with acute ("U+1E82"), etc. are not tailored. The result may depend on whether source strings are normalized or not, and whether decomposed or composed. Thus (normalization => undef) is less preferred.

πŸŒ€ Collation reordering is not supported πŸŒ€

The order of any groups including scripts is not changed.

πŸ“š Reference πŸ“š

here’s the full reference tea. the columns are locale and based CLDR or other reference, and every single row is below β€” no skipping, no cap:

  • af β€” 30 = 1.8.1
  • ar β€” 30 = 28 ("compat" wo [reorder Arab]) = 1.9.0
  • as β€” 30 = 28 (without [reorder Beng..]) = 23
  • az β€” 30 = 24 ("standard" wo [reorder Latn Cyrl])
  • be β€” 30 = 28 (without [reorder Cyrl])
  • bn β€” 30 = 28 ("standard" wo [reorder Beng..]) = 2.0.1
  • bs β€” 30 = 28 (type="standard": [import hr])
  • bs_Cyrl β€” 30 = 28 (type="standard": [import sr])
  • ca β€” 30 = 23 (alt="proposed" type="standard")
  • cs β€” 30 = 1.8.1 (type="standard")
  • cu β€” 34 = 30 (without [reorder Cyrl])
  • cy β€” 30 = 1.8.1
  • da β€” 22.1 = 1.8.1 (type="standard")
  • de__phonebook β€” 30 = 2.0 (type="phonebook")
  • de_AT_phonebook β€” 30 = 27 (type="phonebook")
  • dsb β€” 30 = 26
  • ee β€” 30 = 21
  • eo β€” 30 = 1.8.1
  • es β€” 30 = 1.9.0 (type="standard")
  • es__traditional β€” 30 = 1.8.1 (type="traditional")
  • et β€” 30 = 26
  • fa β€” 22.1 = 1.8.1
  • fi β€” 22.1 = 1.8.1 (type="standard" alt="proposed")
  • fi__phonebook β€” 22.1 = 1.8.1 (type="phonebook")
  • fil β€” 30 = 1.9.0 (type="standard") = 1.8.1
  • fo β€” 22.1 = 1.8.1 (alt="proposed" type="standard")
  • fr_CA β€” 30 = 1.9.0
  • gu β€” 30 = 28 ("standard" wo [reorder Gujr..]) = 1.9.0
  • ha β€” 30 = 1.9.0
  • haw β€” 30 = 24
  • he β€” 30 = 28 (without [reorder Hebr]) = 23
  • hi β€” 30 = 28 (without [reorder Deva..]) = 1.9.0
  • hr β€” 30 = 28 ("standard" wo [reorder Latn Cyrl]) = 1.9.0
  • hu β€” 22.1 = 1.8.1 (alt="proposed" type="standard")
  • hy β€” 30 = 28 (without [reorder Armn]) = 1.8.1
  • ig β€” 30 = 1.8.1
  • is β€” 22.1 = 1.8.1 (type="standard")
  • ja β€” 22.1 = 1.8.1 (type="standard")
  • kk β€” 30 = 28 (without [reorder Cyrl])
  • kl β€” 22.1 = 1.8.1 (type="standard")
  • kn β€” 30 = 28 ("standard" wo [reorder Knda..]) = 1.9.0
  • ko β€” 22.1 = 1.8.1 (type="standard")
  • kok β€” 30 = 28 (without [reorder Deva..]) = 1.8.1
  • lkt β€” 30 = 25
  • ln β€” 30 = 2.0 (type="standard") = 1.8.1
  • lt β€” 22.1 = 1.9.0
  • lv β€” 22.1 = 1.9.0 (type="standard") = 1.8.1
  • mk β€” 30 = 28 (without [reorder Cyrl])
  • ml β€” 22.1 = 1.9.0
  • mr β€” 30 = 28 (without [reorder Deva..]) = 1.8.1
  • mt β€” 22.1 = 1.9.0
  • nb β€” 22.1 = 2.0 (type="standard")
  • nn β€” 22.1 = 2.0 (type="standard")
  • nso β€” [*] 26 = 1.8.1
  • om β€” 22.1 = 1.8.1
  • or β€” 30 = 28 (without [reorder Orya..]) = 1.9.0
  • pa β€” 22.1 = 1.8.1
  • pl β€” 30 = 1.8.1
  • ro β€” 30 = 1.9.0 (type="standard")
  • sa β€” [*] 1.9.1 = 1.8.1 (type="standard" alt="proposed")
  • se β€” 22.1 = 1.8.1 (type="standard")
  • si β€” 30 = 28 ("standard" wo [reorder Sinh..]) = 1.9.0
  • si__dictionary β€” 30 = 28 ("dictionary" wo [reorder Sinh..]) = 1.9.0
  • sk β€” 22.1 = 1.9.0 (type="standard")
  • sl β€” 22.1 = 1.8.1 (type="standard" alt="proposed")
  • sq β€” 22.1 = 1.8.1 (alt="proposed" type="standard")
  • sr β€” 30 = 28 (without [reorder Cyrl])
  • sr_Latn β€” 30 = 28 (type="standard": [import hr])
  • sv β€” 22.1 = 1.9.0 (type="standard")
  • sv__reformed β€” 22.1 = 1.8.1 (type="reformed")
  • ta β€” 22.1 = 1.9.0
  • te β€” 30 = 28 (without [reorder Telu..]) = 1.9.0
  • th β€” 22.1 = 22
  • tn β€” [*] 26 = 1.8.1
  • to β€” 22.1 = 22
  • tr β€” 22.1 = 1.8.1 (type="standard")
  • uk β€” 30 = 28 (without [reorder Cyrl])
  • ug_Cyrl β€” https://en.wikipedia.org/wiki/Uyghur_Cyrillic_alphabet
  • ur β€” 22.1 = 1.9.0
  • vi β€” 22.1 = 1.8.1
  • vo β€” 30 = 25
  • wae β€” 30 = 2.0
  • wo β€” [*] 1.9.1 = 1.8.1
  • yo β€” 30 = 1.8.1
  • zh β€” 22.1 = 1.8.1 (type="standard")
  • zh__big5han β€” 22.1 = 1.8.1 (type="big5han")
  • zh__gb2312han β€” 22.1 = 1.8.1 (type="gb2312han")
  • zh__pinyin β€” 22.1 = 2.0 (type='pinyin' alt='short')
  • zh__stroke β€” 22.1 = 1.9.1 (type='stroke' alt='short')
  • zh__zhuyin β€” 22.1 = 22 (type='zhuyin' alt='short')
the [*] footnote points here, bestie: http://www.unicode.org/repos/cldr/tags/latest/seed/collation/

✍️ AUTHOR ✍️

The Unicode::Collate::Locale module for perl was written by SADAHIRO Tomoyuki, <SADAHIRO@cpan.org>. This module is Copyright(C) 2004-2020, SADAHIRO Tomoyuki. Japan. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

πŸ‘€ SEE ALSO πŸ‘€

okay that’s the whole page, bestie πŸ’– this is the Unicode...:Locale(3pm) page from the Perl Programmers Reference Guide, perl v5.42.3, dated 2026-11-03. go tailor something iconic βœ¨πŸ‘‘

πŸ“¦ where this page comes from