Unicode::Collate::Locale - Linguistic tailoring for DUCET via Unicode::Collate
- use Unicode::Collate::Locale;
- $Collator = Unicode::Collate::Locale->
- new(locale => $locale_name, %tailoring);
- @sorted = $Collator->sort(@not_sorted);
- $result = $Collator->cmp($a, $b); # returns 1, 0, or -1.
Note: Strings in
according to Perl's Unicode support. See perlunicode,
perluniintro, perlunitut, perlunifaq, utf8.
Otherwise you can use
or should decode them before.
This module provides linguistic tailoring for it
taking advantage of
method returns a collator object.
A parameter list for the constructor is a hash, which can include
a special key
and its value (case-insensitive) standing
for a two-letter language code (ISO-639) like
Unicode::Collate::Locale->new(locale => 'FR')
returns a collator tailored for French.
may be suffixed with a territory(country)
code or a variant code, which are separated with
for English in USA,
for Spanish in Spain (Traditional),
is not defined,
fallback is selected in the following order:
- 1. language_territory_variant
- 2. language_territory
- 3. language__variant
- 4. language
- 5. default
Tailoring tags provided by
are allowed as long as
they are not used for
support. Esp. the
is always untailorable since it is reserved for DUCET.
E.g. a collator for French, which ignores diacritics and case difference (i.e. level 1), with reversed case ordering and no normalization.
- level => 1,
- locale => 'fr',
- upper_before_lower => 1,
- normalization => undef
Overriding a behavior already tailored by
if such a tailoring is passed to
- locale => 'da',
- upper_before_lower => 0, # causes error as reserved by 'da'
such a tailoring that is reserved by
is a subclass of
and methods other than
are inherited from
Here is a list of additional methods:
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.
A list of tailorable locales
- locale name description
- af Afrikaans
- ar Arabic
- az Azerbaijani (Azeri)
- be Belarusian
- bg Bulgarian
- ca Catalan
- cs Czech
- cy Welsh
- da Danish
- de__phonebook German (umlaut as 'ae', 'oe', 'ue')
- eo Esperanto
- es Spanish
- es__traditional Spanish ('ch' and 'll' as a grapheme)
- et Estonian
- fi Finnish
- fil Filipino
- fo Faroese
- fr French
- ha Hausa
- haw Hawaiian
- hr Croatian
- hu Hungarian
- hy Armenian
- ig Igbo
- is Icelandic
- ja Japanese 
- kk Kazakh
- kl Kalaallisut
- ko Korean 
- lt Lithuanian
- lv Latvian
- mk Macedonian
- mt Maltese
- nb Norwegian Bokmal
- nn Norwegian Nynorsk
- nso Northern Sotho
- om Oromo
- pl Polish
- ro Romanian
- ru Russian
- se Northern Sami
- sk Slovak
- sl Slovenian
- sq Albanian
- sr Serbian
- sv Swedish
- sw Swahili
- tn Tswana
- to Tonga
- tr Turkish
- uk Ukrainian
- vi Vietnamese
- 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)
- zh__stroke Chinese (ideographs: stroke order)
Locales according to the default UCA rules include de (German), en (English), ga (Irish), id (Indonesian), it (Italian), ka (Georgian), ln (Lingala), ms (Malay), nl (Dutch), pt (Portuguese), st (Southern Sotho), xh (Xhosa), zu (Zulu).
 ja: Ideographs are sorted in JIS X 0208 order.
Fullwidth and halfwidth forms are identical to their normal form.
The difference between hiragana and katakana is at the 4th level,
the comparison also requires
(variable => 'Non-ignorable')
has no effect.
 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.
Collate/Locale/*.pm, Collate/CJK/*.pm and Collate/allkeys.txt.
doesn't require any of data/*.txt,
gendata/*, and mklocale.
are named t/loc_*.t.
- tailoring is not maximum
Even if a certain letter is tailored, its equivalent would not always 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.
The Unicode::Collate::Locale module for perl was written by SADAHIRO Tomoyuki, <SADAHIRO@cpan.org>. This module is Copyright(C) 2004-2011, 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.
- Unicode Collation Algorithm - UTS #10
- The Default Unicode Collation Element Table (DUCET)
- Unicode Locale Data Markup Language (LDML) - UTS #35
- CLDR - Unicode Common Locale Data Repository