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:
- language with a variant code
- language with a script code
- language with a region code
- language
- 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 ofLocale/*.pl.
Note:Locale/*.plthat a collator uses should be identified by a combination of return values fromgetlocaleandlocale_version.
π A list of tailorable locales π
hereβs the whole roster β locale name first, then the description, and donβt skip any, bestie π«Ά
afβ Afrikaansarβ Arabicasβ Assameseazβ Azerbaijani (Azeri)beβ Belarusianbnβ Bengalibsβ Bosnian (tailored as Croatian)bs_Cyrlβ Bosnian in Cyrillic (tailored as Serbian)caβ Catalancsβ Czechcuβ Church Slaviccyβ Welshdaβ Danishde__phonebookβ German (umlaut as 'ae', 'oe', 'ue')de_AT_phonebookβ Austrian German (umlaut primary greater)dsbβ Lower Sorbianeeβ Eweeoβ Esperantoesβ Spanishes__traditionalβ Spanish ('ch' and 'll' as a grapheme)etβ Estonianfaβ Persianfiβ Finnish (v and w are primary equal)fi__phonebookβ Finnish (v and w as separate characters)filβ Filipinofoβ Faroesefr_CAβ Canadian Frenchguβ Gujaratihaβ Hausahawβ Hawaiianheβ Hebrewhiβ Hindihrβ Croatianhuβ Hungarianhyβ Armenianigβ Igboisβ Icelandicjaβ Japanese [1]kkβ Kazakhklβ Kalaallisutknβ Kannadakoβ Korean [2]kokβ Konkanilktβ Lakotalnβ Lingalaltβ Lithuanianlvβ Latvianmkβ Macedonianmlβ Malayalammrβ Marathimtβ Maltesenbβ Norwegian Bokmalnnβ Norwegian Nynorsknsoβ Northern Sothoomβ Oromoorβ Oriyapaβ Punjabiplβ Polishroβ Romaniansaβ Sanskritseβ Northern Samisiβ Sinhalasi__dictionaryβ Sinhala (U+0DA5 = U+0DA2,0DCA,0DA4)skβ Slovakslβ Sloveniansqβ Albaniansrβ Serbiansr_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β Tamilteβ Teluguthβ Thaitnβ Tswanatoβ Tongatrβ Turkishug_Cyrlβ Uyghur in Cyrillicukβ Ukrainianurβ Urduviβ VietnamesevoβVolapu"kwaeβ Walserwoβ Wolofyoβ Yorubazhβ Chinesezh__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:dictphonebookβ alias:phone,phonebkreformedβ alias:reformtraditionalβ alias:tradbig5hanβ alias:big5gb2312hanβ alias:gb2312pinyinstrokezhuyin
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.1arβ30 = 28 ("compat" wo [reorder Arab]) = 1.9.0asβ30 = 28 (without [reorder Beng..]) = 23azβ30 = 24 ("standard" wo [reorder Latn Cyrl])beβ30 = 28 (without [reorder Cyrl])bnβ30 = 28 ("standard" wo [reorder Beng..]) = 2.0.1bsβ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.1daβ22.1 = 1.8.1 (type="standard")de__phonebookβ30 = 2.0 (type="phonebook")de_AT_phonebookβ30 = 27 (type="phonebook")dsbβ30 = 26eeβ30 = 21eoβ30 = 1.8.1esβ30 = 1.9.0 (type="standard")es__traditionalβ30 = 1.8.1 (type="traditional")etβ30 = 26faβ22.1 = 1.8.1fiβ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.1foβ22.1 = 1.8.1 (alt="proposed" type="standard")fr_CAβ30 = 1.9.0guβ30 = 28 ("standard" wo [reorder Gujr..]) = 1.9.0haβ30 = 1.9.0hawβ30 = 24heβ30 = 28 (without [reorder Hebr]) = 23hiβ30 = 28 (without [reorder Deva..]) = 1.9.0hrβ30 = 28 ("standard" wo [reorder Latn Cyrl]) = 1.9.0huβ22.1 = 1.8.1 (alt="proposed" type="standard")hyβ30 = 28 (without [reorder Armn]) = 1.8.1igβ30 = 1.8.1isβ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.0koβ22.1 = 1.8.1 (type="standard")kokβ30 = 28 (without [reorder Deva..]) = 1.8.1lktβ30 = 25lnβ30 = 2.0 (type="standard") = 1.8.1ltβ22.1 = 1.9.0lvβ22.1 = 1.9.0 (type="standard") = 1.8.1mkβ30 = 28 (without [reorder Cyrl])mlβ22.1 = 1.9.0mrβ30 = 28 (without [reorder Deva..]) = 1.8.1mtβ22.1 = 1.9.0nbβ22.1 = 2.0 (type="standard")nnβ22.1 = 2.0 (type="standard")nsoβ[*] 26 = 1.8.1omβ22.1 = 1.8.1orβ30 = 28 (without [reorder Orya..]) = 1.9.0paβ22.1 = 1.8.1plβ30 = 1.8.1roβ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.0si__dictionaryβ30 = 28 ("dictionary" wo [reorder Sinh..]) = 1.9.0skβ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.0teβ30 = 28 (without [reorder Telu..]) = 1.9.0thβ22.1 = 22tnβ[*] 26 = 1.8.1toβ22.1 = 22trβ22.1 = 1.8.1 (type="standard")ukβ30 = 28 (without [reorder Cyrl])ug_Cyrlβhttps://en.wikipedia.org/wiki/Uyghur_Cyrillic_alphabeturβ22.1 = 1.9.0viβ22.1 = 1.8.1voβ30 = 25waeβ30 = 2.0woβ[*] 1.9.1 = 1.8.1yoβ30 = 1.8.1zhβ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 π
- Unicode Collation Algorithm - UTS #10 β
http://www.unicode.org/reports/tr10/ - The Default Unicode Collation Element Table (DUCET) β
http://www.unicode.org/Public/UCA/latest/allkeys.txt - Unicode Locale Data Markup Language (LDML) - UTS #35 β
http://www.unicode.org/reports/tr35/ - CLDR - Unicode Common Locale Data Repository β
http://cldr.unicode.org/ Unicode::CollateUnicode::Normalize
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
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms