{
    "mode": "perldoc",
    "parameter": "Unicode::Collate",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3ACollate/json",
    "generated": "2026-10-05T15:16:21Z",
    "synopsis": "use Unicode::Collate;\n#construct\n$Collator = Unicode::Collate->new(%tailoring);\n#sort\n@sorted = $Collator->sort(@notsorted);\n#compare\n$result = $Collator->cmp($a, $b); # returns 1, 0, or -1.\nNote: Strings in @notsorted, $a and $b are interpreted according to Perl's Unicode support. See\nperlunicode, perluniintro, perlunitut, perlunifaq, utf8. Otherwise you can use \"preprocess\" or\nshould decode them before.",
    "sections": {
        "NAME": {
            "content": "Unicode::Collate - Unicode Collation Algorithm\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Unicode::Collate;\n\n#construct\n$Collator = Unicode::Collate->new(%tailoring);\n\n#sort\n@sorted = $Collator->sort(@notsorted);\n\n#compare\n$result = $Collator->cmp($a, $b); # returns 1, 0, or -1.\n\nNote: Strings in @notsorted, $a and $b are interpreted according to Perl's Unicode support. See\nperlunicode, perluniintro, perlunitut, perlunifaq, utf8. Otherwise you can use \"preprocess\" or\nshould decode them before.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module is an implementation of Unicode Technical Standard #10 (a.k.a. UTS #10) - Unicode\nCollation Algorithm (a.k.a. UCA).\n",
            "subsections": [
                {
                    "name": "Constructor and Tailoring",
                    "content": "The \"new\" method returns a collator object. If new() is called with no parameters, the collator\nshould do the default collation.\n\n$Collator = Unicode::Collate->new(\nUCAVersion => $UCAVersion,\nalternate => $alternate, # alias for 'variable'\nbackwards => $levelNumber, # or \\@levelNumbers\nentry => $element,\nhangulterminator => $termprimaryweight,\nhighestFFFF => $bool,\nidentical => $bool,\nignoreName => qr/$ignoreName/,\nignoreChar => qr/$ignoreChar/,\nignorelevel2 => $bool,\nkatakanabeforehiragana => $bool,\nlevel => $collationLevel,\nlongcontraction => $bool,\nminimalFFFE => $bool,\nnormalization  => $normalizationform,\noverrideCJK => \\&overrideCJK,\noverrideHangul => \\&overrideHangul,\npreprocess => \\&preprocess,\nrearrange => \\@charList,\nrewrite => \\&rewrite,\nsuppress => \\@charList,\ntable => $filename,\nundefName => qr/$undefName/,\nundefChar => qr/$undefChar/,\nupperbeforelower => $bool,\nvariable => $variable,\n);\n\nUCAVersion\nIf the revision (previously \"tracking version\") number of UCA is given, behavior of that\nrevision is emulated on collating. If omitted, the return value of UCAVersion() is used.\n\nThe following revisions are supported. The default is 43.\n\nUCA       Unicode Standard         DUCET (@version)\n-------------------------------------------------------\n8              3.1                3.0.1 (3.0.1d9)\n9     3.1 with Corrigendum 3      3.1.1\n11             4.0.0\n14             4.1.0\n16             5.0.0\n18             5.1.0\n20             5.2.0\n22             6.0.0\n24             6.1.0\n26             6.2.0\n28             6.3.0\n30             7.0.0\n32             8.0.0\n34             9.0.0\n36            10.0.0\n38            11.0.0\n40            12.0.0\n41            12.1.0\n43            13.0.0\n\n* See below for \"longcontraction\" with \"UCAVersion\" 22 and 24.\n\n* Noncharacters (e.g. U+FFFF) are not ignored, and can be overridden since \"UCAVersion\" 22.\n\n* Out-of-range codepoints (greater than U+10FFFF) are not ignored, and can be overridden\nsince \"UCAVersion\" 22.\n\n* Fully ignorable characters were ignored, and would not interrupt contractions with\n\"UCAVersion\" 9 and 11.\n\n* Treatment of ignorables after variables and some behaviors were changed at \"UCAVersion\"\n9.\n\n* Characters regarded as CJK unified ideographs (cf. \"overrideCJK\") depend on \"UCAVersion\".\n\n* Many hangul jamo are assigned at \"UCAVersion\" 20, that will affect \"hangulterminator\".\n\nalternate\n-- see 3.2.2 Alternate Weighting, version 8 of UTS #10\n\nFor backward compatibility, \"alternate\" (old name) can be used as an alias for \"variable\".\n\nbackwards\n-- see 3.4 Backward Accents, UTS #10.\n\nbackwards => $levelNumber or \\@levelNumbers\n\nWeights in reverse order; ex. level 2 (diacritic ordering) in French. If omitted (or\n$levelNumber is \"undef\" or \"\\@levelNumbers\" is \"[]\"), forwards at all the levels.\n\nentry\n-- see 5 Tailoring; 9.1 Allkeys File Format, UTS #10.\n\nIf the same character (or a sequence of characters) exists in the collation element table\nthrough \"table\", mapping to collation elements is overridden. If it does not exist, the\nmapping is defined additionally.\n\nentry => <<'ENTRY', # for DUCET v4.0.0 (allkeys-4.0.0.txt)\n0063 0068 ; [.0E6A.0020.0002.0063] # ch\n0043 0068 ; [.0E6A.0020.0007.0043] # Ch\n0043 0048 ; [.0E6A.0020.0008.0043] # CH\n006C 006C ; [.0F4C.0020.0002.006C] # ll\n004C 006C ; [.0F4C.0020.0007.004C] # Ll\n004C 004C ; [.0F4C.0020.0008.004C] # LL\n00F1      ; [.0F7B.0020.0002.00F1] # n-tilde\n006E 0303 ; [.0F7B.0020.0002.00F1] # n-tilde\n00D1      ; [.0F7B.0020.0008.00D1] # N-tilde\n004E 0303 ; [.0F7B.0020.0008.00D1] # N-tilde\nENTRY\n\nentry => <<'ENTRY', # for DUCET v4.0.0 (allkeys-4.0.0.txt)\n00E6 ; [.0E33.0020.0002.00E6][.0E8B.0020.0002.00E6] # ae ligature as <a><e>\n00C6 ; [.0E33.0020.0008.00C6][.0E8B.0020.0008.00C6] # AE ligature as <A><E>\nENTRY\n\nNOTE: The code point in the UCA file format (before ';') must be a Unicode code point\n(defined as hexadecimal), but not a native code point. So 0063 must always denote \"U+0063\",\nbut not a character of \"\\x63\".\n\nWeighting may vary depending on collation element table. So ensure the weights defined in\n\"entry\" will be consistent with those in the collation element table loaded via \"table\".\n\nIn DUCET v4.0.0, primary weight of \"C\" is 0E60 and that of \"D\" is \"0E6D\". So setting primary\nweight of \"CH\" to \"0E6A\" (as a value between 0E60 and \"0E6D\") makes ordering as \"C < CH <\nD\". Exactly speaking DUCET already has some characters between \"C\" and \"D\": \"small capital\nC\" (\"U+1D04\") with primary weight 0E64, \"c-hook/C-hook\" (\"U+0188/U+0187\") with 0E65, and\n\"c-curl\" (\"U+0255\") with 0E69. Then primary weight \"0E6A\" for \"CH\" makes \"CH\" ordered\nbetween \"c-curl\" and \"D\".\n\nhangulterminator\n-- see 7.1.4 Trailing Weights, UTS #10.\n\nIf a true value is given (non-zero but should be positive), it will be added as a terminator\nprimary weight to the end of every standard Hangul syllable. Secondary and any higher\nweights for terminator are set to zero. If the value is false or \"hangulterminator\" key\ndoes not exist, insertion of terminator weights will not be performed.\n\nBoundaries of Hangul syllables are determined according to conjoining Jamo behavior in the\nUnicode Standard and HangulSyllableType.txt.\n\nImplementation Note: (1) For expansion mapping (Unicode character mapped to a sequence of\ncollation elements), a terminator will not be added between collation elements, even if\nHangul syllable boundary exists there. Addition of terminator is restricted to the next\nposition to the last collation element.\n\n(2) Non-conjoining Hangul letters (Compatibility Jamo, halfwidth Jamo, and enclosed letters)\nare not automatically terminated with a terminator primary weight. These characters may need\nterminator included in a collation element table beforehand.\n\nhighestFFFF\n-- see 2.4 Tailored noncharacter weights, UTS #35 (LDML) Part 5: Collation.\n\nIf the parameter is made true, \"U+FFFF\" has a highest primary weight. When a boolean of\n\"$coll->ge($str, \"abc\")\" and \"$coll->le($str, \"abc\\x{FFFF}\")\" is true, it is expected that\n$str begins with \"abc\", or another primary equivalent. $str may be \"abcd\", \"abc012\", but\nshould not include \"U+FFFF\" such as \"abc\\x{FFFF}xyz\".\n\n\"$coll->le($str, \"abc\\x{FFFF}\")\" works like \"$coll->lt($str, \"abd\")\" almost, but the latter\nhas a problem that you should know which letter is next to \"c\". For a certain language where\n\"ch\" as the next letter, \"abch\" is greater than \"abc\\x{FFFF}\", but less than \"abd\".\n\nNote: This is equivalent to \"(entry => 'FFFF ; [.FFFE.0020.0005.FFFF]')\". Any other\ncharacter than \"U+FFFF\" can be tailored by \"entry\".\n\nidentical\n-- see A.3 Deterministic Comparison, UTS #10.\n\nBy default, strings whose weights are equal should be equal, even though their code points\nare not equal. Completely ignorable characters are ignored.\n\nIf the parameter is made true, a final, tie-breaking level is used. If no difference of\nweights is found after the comparison through all the level specified by \"level\", the\ncomparison with code points will be performed. For the tie-breaking comparison, the sort key\nhas code points of the original string appended. Completely ignorable characters are not\nignored.\n\nIf \"preprocess\" and/or \"normalization\" is applied, the code points of the string after them\n(in NFD by default) are used.\n\nignoreChar\nignoreName\n-- see 3.6 Variable Weighting, UTS #10.\n\nMakes the entry in the table completely ignorable; i.e. as if the weights were zero at all\nlevel.\n\nThrough \"ignoreChar\", any character matching \"qr/$ignoreChar/\" will be ignored. Through\n\"ignoreName\", any character whose name (given in the \"table\" file as a comment) matches\n\"qr/$ignoreName/\" will be ignored.\n\nE.g. when 'a' and 'e' are ignorable, 'element' is equal to 'lament' (or 'lmnt').\n\nignorelevel2\n-- see 5.1 Parametric Tailoring, UTS #10.\n\nBy default, case-sensitive comparison (that is level 3 difference) won't ignore accents\n(that is level 2 difference).\n\nIf the parameter is made true, accents (and other primary ignorable characters) are ignored,\neven though cases are taken into account.\n\nNOTE: \"level\" should be 3 or greater.\n\nkatakanabeforehiragana\n-- see 7.2 Tertiary Weight Table, UTS #10.\n\nBy default, hiragana is before katakana. If the parameter is made true, this is reversed.\n\nNOTE: This parameter simplemindedly assumes that any hiragana/katakana distinctions must\noccur in level 3, and their weights at level 3 must be same as those mentioned in 7.3.1, UTS\n#10. If you define your collation elements which violate this requirement, this parameter\ndoes not work validly.\n\nlevel\n-- see 4.3 Form Sort Key, UTS #10.\n\nSet the maximum level. Any higher levels than the specified one are ignored.\n\nLevel 1: alphabetic ordering\nLevel 2: diacritic ordering\nLevel 3: case ordering\nLevel 4: tie-breaking (e.g. in the case when variable is 'shifted')\n\nex.level => 2,\n\nIf omitted, the maximum is the 4th.\n\nNOTE: The DUCET includes weights over 0xFFFF at the 4th level. But this module only uses\nweights within 0xFFFF. When \"variable\" is 'blanked' or 'non-ignorable' (other than 'shifted'\nand 'shift-trimmed'), the level 4 may be unreliable.\n\nSee also \"identical\".\n\nlongcontraction\n-- see 3.8.2 Well-Formedness of the DUCET, 4.2 Produce Array, UTS #10.\n\nIf the parameter is made true, for a contraction with three or more characters (here\nnicknamed \"long contraction\"), initial substrings will be handled. For example, a\ncontraction ABC, where A is a starter, and B and C are non-starters (character with non-zero\ncombining character class), will be detected even if there is not AB as a contraction.\n\nDefault: Usually false. If \"UCAVersion\" is 22 or 24, and the value of \"longcontraction\" is\nnot specified in new(), a true value is set implicitly. This is a workaround to pass\nConformance Tests for Unicode 6.0.0 and 6.1.0.\n\nchange() handles \"longcontraction\" explicitly only. If \"longcontraction\" is not specified\nin change(), even though \"UCAVersion\" is changed, \"longcontraction\" will not be changed.\n\nLimitation: Scanning non-starters is one-way (no back tracking). If AB is found but not ABC\nis not found, other long contraction where the first character is A and the second is not B\nmay not be found.\n\nUnder \"(normalization => undef)\", detection step of discontiguous contractions will be\nskipped.\n\nNote: The following contractions in DUCET are not considered in steps S2.1.1 to S2.1.3,\nwhere they are discontiguous.\n\n0FB2 0F71 0F80 (TIBETAN VOWEL SIGN VOCALIC RR)\n0FB3 0F71 0F80 (TIBETAN VOWEL SIGN VOCALIC LL)\n\nFor example \"TIBETAN VOWEL SIGN VOCALIC RR\" with \"COMBINING TILDE OVERLAY\" (\"U+0344\") is\n\"0FB2 0344 0F71 0F80\" in NFD. In this case \"0FB2 0F80\" (\"TIBETAN VOWEL SIGN VOCALIC R\") is\ndetected, instead of \"0FB2 0F71 0F80\". Inserted 0344 makes \"0FB2 0F71 0F80\" discontiguous\nand lack of contraction \"0FB2 0F71\" prohibits \"0FB2 0F71 0F80\" from being detected.\n\nminimalFFFE\n-- see 1.1.1 U+FFFE, UTS #35 (LDML) Part 5: Collation.\n\nIf the parameter is made true, \"U+FFFE\" has a minimal primary weight. The comparison between\n\"$a1\\x{FFFE}$a2\" and \"$b1\\x{FFFE}$b2\" first compares $a1 and $b1 at level 1, and then $a2\nand $b2 at level 1, as followed.\n\n\"ab\\x{FFFE}a\"\n\"Ab\\x{FFFE}a\"\n\"ab\\x{FFFE}c\"\n\"Ab\\x{FFFE}c\"\n\"ab\\x{FFFE}xyz\"\n\"abc\\x{FFFE}def\"\n\"abc\\x{FFFE}xYz\"\n\"aBc\\x{FFFE}xyz\"\n\"abcX\\x{FFFE}def\"\n\"abcx\\x{FFFE}xyz\"\n\"b\\x{FFFE}aaa\"\n\"bbb\\x{FFFE}a\"\n\nNote: This is equivalent to \"(entry => 'FFFE ; [.0001.0020.0005.FFFE]')\". Any other\ncharacter than \"U+FFFE\" can be tailored by \"entry\".\n\nnormalization\n-- see 4.1 Normalize, UTS #10.\n\nIf specified, strings are normalized before preparation of sort keys (the normalization is\nexecuted after preprocess).\n\nA form name Unicode::Normalize::normalize() accepts will be applied as $normalizationform.\nAcceptable names include 'NFD', 'NFC', 'NFKD', and 'NFKC'. See\nUnicode::Normalize::normalize() for detail. If omitted, 'NFD' is used.\n\n\"normalization\" is performed after \"preprocess\" (if defined).\n\nFurthermore, special values, \"undef\" and \"prenormalized\", can be used, though they are not\nconcerned with Unicode::Normalize::normalize().\n\nIf \"undef\" (not a string \"undef\") is passed explicitly as the value for this key, any\nnormalization is not carried out (this may make tailoring easier if any normalization is not\ndesired). Under \"(normalization => undef)\", only contiguous contractions are resolved; e.g.\neven if \"A-ring\" (and \"A-ring-cedilla\") is ordered after \"Z\", \"A-cedilla-ring\" would be\nprimary equal to \"A\". In this point, \"(normalization => undef, preprocess => sub {\nNFD(shift) })\" is not equivalent to \"(normalization => 'NFD')\".\n\nIn the case of \"(normalization => \"prenormalized\")\", any normalization is not performed, but\ndiscontiguous contractions with combining characters are performed. Therefore\n\"(normalization => 'prenormalized', preprocess => sub { NFD(shift) })\" is equivalent to\n\"(normalization => 'NFD')\". If source strings are finely prenormalized, \"(normalization =>\n'prenormalized')\" may save time for normalization.\n\nExcept \"(normalization => undef)\", Unicode::Normalize is required (see also CAVEAT).\n\noverrideCJK\n-- see 7.1 Derived Collation Elements, UTS #10.\n\nBy default, CJK unified ideographs are ordered in Unicode codepoint order, but those in the\nCJK Unified Ideographs block are less than those in the CJK Unified Ideographs Extension A\netc.\n\nIn the CJK Unified Ideographs block:\nU+4E00..U+9FA5 if UCAVersion is 8, 9 or 11.\nU+4E00..U+9FBB if UCAVersion is 14 or 16.\nU+4E00..U+9FC3 if UCAVersion is 18.\nU+4E00..U+9FCB if UCAVersion is 20 or 22.\nU+4E00..U+9FCC if UCAVersion is 24 to 30.\nU+4E00..U+9FD5 if UCAVersion is 32 or 34.\nU+4E00..U+9FEA if UCAVersion is 36.\nU+4E00..U+9FEF if UCAVersion is 38, 40 or 41.\nU+4E00..U+9FFC if UCAVersion is 43.\n\nIn the CJK Unified Ideographs Extension blocks:\nExt.A (U+3400..U+4DB5)   if UCAVersion is  8 to 41.\nExt.A (U+3400..U+4DBF)   if UCAVersion is 43.\nExt.B (U+20000..U+2A6D6) if UCAVersion is  8 to 41.\nExt.B (U+20000..U+2A6DD) if UCAVersion is 43.\nExt.C (U+2A700..U+2B734) if UCAVersion is 20 or later.\nExt.D (U+2B740..U+2B81D) if UCAVersion is 22 or later.\nExt.E (U+2B820..U+2CEA1) if UCAVersion is 32 or later.\nExt.F (U+2CEB0..U+2EBE0) if UCAVersion is 36 or later.\nExt.G (U+30000..U+3134A) if UCAVersion is 43.\n\nThrough \"overrideCJK\", ordering of CJK unified ideographs (including extensions) can be\noverridden.\n\nex. CJK unified ideographs in the JIS code point order.\n\noverrideCJK => sub {\nmy $u = shift;             # get a Unicode codepoint\nmy $b = pack('n', $u);     # to UTF-16BE\nmy $s = yourunicodetosjisconverter($b); # convert\nmy $n = unpack('n', $s);   # convert sjis to short\n[ $n, 0x20, 0x2, $u ];     # return the collation element\n},\n\nThe return value may be an arrayref of 1st to 4th weights as shown above. The return value\nmay be an integer as the primary weight as shown below. If \"undef\" is returned, the default\nderived collation element will be used.\n\noverrideCJK => sub {\nmy $u = shift;             # get a Unicode codepoint\nmy $b = pack('n', $u);     # to UTF-16BE\nmy $s = yourunicodetosjisconverter($b); # convert\nmy $n = unpack('n', $s);   # convert sjis to short\nreturn $n;                 # return the primary weight\n},\n\nThe return value may be a list containing zero or more of an arrayref, an integer, or\n\"undef\".\n\nex. ignores all CJK unified ideographs.\n\noverrideCJK => sub {()}, # CODEREF returning empty list\n\n# where ->eq(\"Pe\\x{4E00}rl\", \"Perl\") is true\n# as U+4E00 is a CJK unified ideograph and to be ignorable.\n\nIf a false value (including \"undef\") is passed, \"overrideCJK\" has no effect.\n\"$Collator->change(overrideCJK => 0)\" resets the old one.\n\nBut assignment of weight for CJK unified ideographs in \"table\" or \"entry\" is still valid. If\n\"undef\" is passed explicitly as the value for this key, weights for CJK unified ideographs\nare treated as undefined. However when \"UCAVersion\" > 8, \"(overrideCJK => undef)\" has no\nspecial meaning.\n\nNote: In addition to them, 12 CJK compatibility ideographs (\"U+FA0E\", \"U+FA0F\", \"U+FA11\",\n\"U+FA13\", \"U+FA14\", \"U+FA1F\", \"U+FA21\", \"U+FA23\", \"U+FA24\", \"U+FA27\", \"U+FA28\", \"U+FA29\")\nare also treated as CJK unified ideographs. But they can't be overridden via \"overrideCJK\"\nwhen you use DUCET, as the table includes weights for them. \"table\" or \"entry\" has priority\nover \"overrideCJK\".\n\noverrideHangul\n-- see 7.1 Derived Collation Elements, UTS #10.\n\nBy default, Hangul syllables are decomposed into Hangul Jamo, even if \"(normalization =>\nundef)\". But the mapping of Hangul syllables may be overridden.\n\nThis parameter works like \"overrideCJK\", so see there for examples.\n\nIf you want to override the mapping of Hangul syllables, NFD and NFKD are not appropriate,\nsince NFD and NFKD will decompose Hangul syllables before overriding. FCD may decompose\nHangul syllables as the case may be.\n\nIf a false value (but not \"undef\") is passed, \"overrideHangul\" has no effect.\n\"$Collator->change(overrideHangul => 0)\" resets the old one.\n\nIf \"undef\" is passed explicitly as the value for this key, weight for Hangul syllables is\ntreated as undefined without decomposition into Hangul Jamo. But definition of weight for\nHangul syllables in \"table\" or \"entry\" is still valid.\n\noverrideOut\n-- see 7.1.1 Handling Ill-Formed Code Unit Sequences, UTS #10.\n\nPerl seems to allow out-of-range values (greater than 0x10FFFF). By default, out-of-range\nvalues are replaced with \"U+FFFD\" (REPLACEMENT CHARACTER) when \"UCAVersion\" >= 22, or\nignored when \"UCAVersion\" <= 20.\n\nWhen \"UCAVersion\" >= 22, the weights of out-of-range values can be overridden. Though\n\"table\" or \"entry\" are available for them, out-of-range values are too many.\n\n\"overrideOut\" can perform it algorithmically. This parameter works like \"overrideCJK\", so\nsee there for examples.\n\nex. ignores all out-of-range values.\n\noverrideOut => sub {()}, # CODEREF returning empty list\n\nIf a false value (including \"undef\") is passed, \"overrideOut\" has no effect.\n\"$Collator->change(overrideOut => 0)\" resets the old one.\n\nNOTE ABOUT U+FFFD:\n\nUCA recommends that out-of-range values should not be ignored for security reasons. Say,\n\"pe\\x{110000}rl\" should not be equal to \"perl\". However, \"U+FFFD\" is wrongly mapped to a\nvariable collation element in DUCET for Unicode 6.0.0 to 6.2.0, that means out-of-range\nvalues will be ignored when \"variable\" isn't \"Non-ignorable\".\n\nThe mapping of \"U+FFFD\" is corrected in Unicode 6.3.0. see\n<http://www.unicode.org/reports/tr10/tr10-28.html#TrailingWeights> (7.1.4 Trailing\nWeights). Such a correction is reproduced by this.\n\noverrideOut => sub { 0xFFFD }, # CODEREF returning a very large integer\n\nThis workaround is unnecessary since Unicode 6.3.0.\n\npreprocess\n-- see 5.4 Preprocessing, UTS #10.\n\nIf specified, the coderef is used to preprocess each string before the formation of sort\nkeys.\n\nex. dropping English articles, such as \"a\" or \"the\". Then, \"the pen\" is before \"a pencil\".\n\npreprocess => sub {\nmy $str = shift;\n$str =~ s/\\b(?:an?|the)\\s+//gi;\nreturn $str;\n},\n\n\"preprocess\" is performed before \"normalization\" (if defined).\n\nex. decoding strings in a legacy encoding such as shift-jis:\n\n$sjiscollator = Unicode::Collate->new(\npreprocess => \\&yourshiftjistounicodedecoder,\n);\n@result = $sjiscollator->sort(@shiftjisstrings);\n\nNote: Strings returned from the coderef will be interpreted according to Perl's Unicode\nsupport. See perlunicode, perluniintro, perlunitut, perlunifaq, utf8.\n\nrearrange\n-- see 3.5 Rearrangement, UTS #10.\n\nCharacters that are not coded in logical order and to be rearranged. If \"UCAVersion\" is\nequal to or less than 11, default is:\n\nrearrange => [ 0x0E40..0x0E44, 0x0EC0..0x0EC4 ],\n\nIf you want to disallow any rearrangement, pass \"undef\" or \"[]\" (a reference to empty list)\nas the value for this key.\n\nIf \"UCAVersion\" is equal to or greater than 14, default is \"[]\" (i.e. no rearrangement).\n\nAccording to the version 9 of UCA, this parameter shall not be used; but it is not warned at\npresent.\n\nrewrite\nIf specified, the coderef is used to rewrite lines in \"table\" or \"entry\". The coderef will\nget each line, and then should return a rewritten line according to the UCA file format. If\nthe coderef returns an empty line, the line will be skipped.\n\ne.g. any primary ignorable characters into tertiary ignorable:\n\nrewrite => sub {\nmy $line = shift;\n$line =~ s/\\[\\.0000\\..{4}\\..{4}\\./[.0000.0000.0000./g;\nreturn $line;\n},\n\nThis example shows rewriting weights. \"rewrite\" is allowed to affect code points, weights,\nand the name.\n\nNOTE: \"table\" is available to use another table file; preparing a modified table once would\nbe more efficient than rewriting lines on reading an unmodified table every time.\n\nsuppress\n-- see 3.12 Special-Purpose Commands, UTS #35 (LDML) Part 5: Collation.\n\nContractions beginning with the specified characters are suppressed, even if those\ncontractions are defined in \"table\".\n\nAn example for Russian and some languages using the Cyrillic script:\n\nsuppress => [0x0400..0x0417, 0x041A..0x0437, 0x043A..0x045F],\n\nwhere 0x0400 stands for \"U+0400\", CYRILLIC CAPITAL LETTER IE WITH GRAVE.\n\nNOTE: Contractions via \"entry\" will not be suppressed.\n\ntable\n-- see 3.8 Default Unicode Collation Element Table, UTS #10.\n\nYou can use another collation element table if desired.\n\nThe table file should locate in the Unicode/Collate directory on @INC. Say, if the filename\nis Foo.txt, the table file is searched as Unicode/Collate/Foo.txt in @INC.\n\nBy default, allkeys.txt (as the filename of DUCET) is used. If you will prepare your own\ntable file, any name other than allkeys.txt may be better to avoid namespace conflict.\n\nNOTE: When XSUB is used, the DUCET is compiled on building this module, and it may save time\nat the run time. Explicit saying \"(table => 'allkeys.txt')\", or using another table, or\nusing \"ignoreChar\", \"ignoreName\", \"undefChar\", \"undefName\" or \"rewrite\" will prevent this\nmodule from using the compiled DUCET.\n\nIf \"undef\" is passed explicitly as the value for this key, no file is read (but you can\ndefine collation elements via \"entry\").\n\nA typical way to define a collation element table without any file of table:\n\n$onlyABC = Unicode::Collate->new(\ntable => undef,\nentry => << 'ENTRIES',\n0061 ; [.0101.0020.0002.0061] # LATIN SMALL LETTER A\n0041 ; [.0101.0020.0008.0041] # LATIN CAPITAL LETTER A\n0062 ; [.0102.0020.0002.0062] # LATIN SMALL LETTER B\n0042 ; [.0102.0020.0008.0042] # LATIN CAPITAL LETTER B\n0063 ; [.0103.0020.0002.0063] # LATIN SMALL LETTER C\n0043 ; [.0103.0020.0008.0043] # LATIN CAPITAL LETTER C\nENTRIES\n);\n\nIf \"ignoreName\" or \"undefName\" is used, character names should be specified as a comment\n(following \"#\") on each line.\n\nundefChar\nundefName\n-- see 6.3.3 Reducing the Repertoire, UTS #10.\n\nUndefines the collation element as if it were unassigned in the \"table\". This reduces the\nsize of the table. If an unassigned character appears in the string to be collated, the sort\nkey is made from its codepoint as a single-character collation element, as it is greater\nthan any other assigned collation elements (in the codepoint order among the unassigned\ncharacters). But, it'd be better to ignore characters unfamiliar to you and maybe never\nused.\n\nThrough \"undefChar\", any character matching \"qr/$undefChar/\" will be undefined. Through\n\"undefName\", any character whose name (given in the \"table\" file as a comment) matches\n\"qr/$undefName/\" will be undefined.\n\nex. Collation weights for beyond-BMP characters are not stored in object:\n\nundefChar => qr/[^\\0-\\x{fffd}]/,\n\nupperbeforelower\n-- see 6.6 Case Comparisons, UTS #10.\n\nBy default, lowercase is before uppercase. If the parameter is made true, this is reversed.\n\nNOTE: This parameter simplemindedly assumes that any lowercase/uppercase distinctions must\noccur in level 3, and their weights at level 3 must be same as those mentioned in 7.3.1, UTS\n#10. If you define your collation elements which differs from this requirement, this\nparameter doesn't work validly.\n\nvariable\n-- see 3.6 Variable Weighting, UTS #10.\n\nThis key allows for variable weighting of variable collation elements, which are marked with\nan ASTERISK in the table (NOTE: Many punctuation marks and symbols are variable in\nallkeys.txt).\n\nvariable => 'blanked', 'non-ignorable', 'shifted', or 'shift-trimmed'.\n\nThese names are case-insensitive. By default (if specification is omitted), 'shifted' is\nadopted.\n\n'Blanked'        Variable elements are made ignorable at levels 1 through 3;\nconsidered at the 4th level.\n\n'Non-Ignorable'  Variable elements are not reset to ignorable.\n\n'Shifted'        Variable elements are made ignorable at levels 1 through 3\ntheir level 4 weight is replaced by the old level 1 weight.\nLevel 4 weight for Non-Variable elements is 0xFFFF.\n\n'Shift-Trimmed'  Same as 'shifted', but all FFFF's at the 4th level\nare trimmed.\n"
                },
                {
                    "name": "Methods for Collation",
                    "content": "\"@sorted = $Collator->sort(@notsorted)\"\nSorts a list of strings.\n\n\"$result = $Collator->cmp($a, $b)\"\nReturns 1 (when $a is greater than $b) or 0 (when $a is equal to $b) or -1 (when $a is less\nthan $b).\n\n\"$result = $Collator->eq($a, $b)\"\n\"$result = $Collator->ne($a, $b)\"\n\"$result = $Collator->lt($a, $b)\"\n\"$result = $Collator->le($a, $b)\"\n\"$result = $Collator->gt($a, $b)\"\n\"$result = $Collator->ge($a, $b)\"\nThey works like the same name operators as theirs.\n\neq : whether $a is equal to $b.\nne : whether $a is not equal to $b.\nlt : whether $a is less than $b.\nle : whether $a is less than $b or equal to $b.\ngt : whether $a is greater than $b.\nge : whether $a is greater than $b or equal to $b.\n\n\"$sortKey = $Collator->getSortKey($string)\"\n-- see 4.3 Form Sort Key, UTS #10.\n\nReturns a sort key.\n\nYou compare the sort keys using a binary comparison and get the result of the comparison of\nthe strings using UCA.\n\n$Collator->getSortKey($a) cmp $Collator->getSortKey($b)\n\nis equivalent to\n\n$Collator->cmp($a, $b)\n\n\"$sortKeyForm = $Collator->viewSortKey($string)\"\nConverts a sorting key into its representation form. If \"UCAVersion\" is 8, the output is\nslightly different.\n\nuse Unicode::Collate;\nmy $c = Unicode::Collate->new();\nprint $c->viewSortKey(\"Perl\"),\"\\n\";\n\n# output:\n# [0B67 0A65 0B7F 0B03 | 0020 0020 0020 0020 | 0008 0002 0002 0002 | FFFF FFFF FFFF FFFF]\n#  Level 1               Level 2               Level 3               Level 4\n"
                },
                {
                    "name": "Methods for Searching",
                    "content": "The \"match\", \"gmatch\", \"subst\", \"gsubst\" methods work like \"m//\", \"m//g\", \"s///\", \"s///g\",\nrespectively, but they are not aware of any pattern, but only a literal substring.\n\nDISCLAIMER: If \"preprocess\" or \"normalization\" parameter is true for $Collator, calling these\nmethods (\"index\", \"match\", \"gmatch\", \"subst\", \"gsubst\") is croaked, as the position and the\nlength might differ from those on the specified string.\n\n\"rearrange\" and \"hangulterminator\" parameters are neglected. \"katakanabeforehiragana\" and\n\"upperbeforelower\" don't affect matching and searching, as it doesn't matter whether greater\nor less.\n\n\"$position = $Collator->index($string, $substring[, $position])\"\n\"($position, $length) = $Collator->index($string, $substring[, $position])\"\nIf $substring matches a part of $string, returns the position of the first occurrence of the\nmatching part in scalar context; in list context, returns a two-element list of the position\nand the length of the matching part.\n\nIf $substring does not match any part of $string, returns -1 in scalar context and an empty\nlist in list context.\n\ne.g. when the content of $str is \"\"Ich mu\"ß\" studieren Perl.\"\", you say the following where\n$sub is \"\"M\"ü\"SS\"\",\n\nmy $Collator = Unicode::Collate->new( normalization => undef, level => 1 );\n# (normalization => undef) is REQUIRED.\nmy $match;\nif (my($pos,$len) = $Collator->index($str, $sub)) {\n$match = substr($str, $pos, $len);\n}\n\nand get \"\"mu\"ß\"\"\" in $match, since \"\"mu\"ß\"\"\" is primary equal to \"\"M\"ü\"SS\"\".\n\n\"$matchref = $Collator->match($string, $substring)\"\n\"($match) = $Collator->match($string, $substring)\"\nIf $substring matches a part of $string, in scalar context, returns a reference to the first\noccurrence of the matching part ($matchref is always true if matches, since every reference\nis true); in list context, returns the first occurrence of the matching part.\n\nIf $substring does not match any part of $string, returns \"undef\" in scalar context and an\nempty list in list context.\n\ne.g.\n\nif ($matchref = $Collator->match($str, $sub)) { # scalar context\nprint \"matches [$$matchref].\\n\";\n} else {\nprint \"doesn't match.\\n\";\n}\n\nor\n\nif (($match) = $Collator->match($str, $sub)) { # list context\nprint \"matches [$match].\\n\";\n} else {\nprint \"doesn't match.\\n\";\n}\n\n\"@match = $Collator->gmatch($string, $substring)\"\nIf $substring matches a part of $string, returns all the matching parts (or matching count\nin scalar context).\n\nIf $substring does not match any part of $string, returns an empty list.\n\n\"$count = $Collator->subst($string, $substring, $replacement)\"\nIf $substring matches a part of $string, the first occurrence of the matching part is\nreplaced by $replacement ($string is modified) and $count (always equals to 1) is returned.\n\n$replacement can be a \"CODEREF\", taking the matching part as an argument, and returning a\nstring to replace the matching part (a bit similar to \"s/(..)/$coderef->($1)/e\").\n\n\"$count = $Collator->gsubst($string, $substring, $replacement)\"\nIf $substring matches a part of $string, all the occurrences of the matching part are\nreplaced by $replacement ($string is modified) and $count is returned.\n\n$replacement can be a \"CODEREF\", taking the matching part as an argument, and returning a\nstring to replace the matching part (a bit similar to \"s/(..)/$coderef->($1)/eg\").\n\ne.g.\n\nmy $Collator = Unicode::Collate->new( normalization => undef, level => 1 );\n# (normalization => undef) is REQUIRED.\nmy $str = \"Camel donkey zebra came\\x{301}l CAMEL horse cam\\0e\\0l...\";\n$Collator->gsubst($str, \"camel\", sub { \"<b>$[0]</b>\" });\n\n# now $str is \"<b>Camel</b> donkey zebra <b>came\\x{301}l</b> <b>CAMEL</b> horse <b>cam\\0e\\0l</b>...\";\n# i.e., all the camels are made bold-faced.\n\nExamples: levels and ignorelevel2 - what does camel match?\n---------------------------------------------------------------------------\nlevel  ignorelevel2  |  camel  Camel  came\\x{301}l  c-a-m-e-l  cam\\0e\\0l\n-----------------------|---------------------------------------------------\n1        false      |   yes    yes      yes          yes        yes\n2        false      |   yes    yes      no           yes        yes\n3        false      |   yes    no       no           yes        yes\n4        false      |   yes    no       no           no         yes\n-----------------------|---------------------------------------------------\n1        true       |   yes    yes      yes          yes        yes\n2        true       |   yes    yes      yes          yes        yes\n3        true       |   yes    no       yes          yes        yes\n4        true       |   yes    no       yes          no         yes\n---------------------------------------------------------------------------\nnote: if variable => non-ignorable, camel doesn't match c-a-m-e-l\nat any level.\n"
                },
                {
                    "name": "Other Methods",
                    "content": "\"%oldtailoring = $Collator->change(%newtailoring)\"\n\"$modifiedcollator = $Collator->change(%newtailoring)\"\nChanges the value of specified keys and returns the changed part.\n\n$Collator = Unicode::Collate->new(level => 4);\n\n$Collator->eq(\"perl\", \"PERL\"); # false\n\n%old = $Collator->change(level => 2); # returns (level => 4).\n\n$Collator->eq(\"perl\", \"PERL\"); # true\n\n$Collator->change(%old); # returns (level => 2).\n\n$Collator->eq(\"perl\", \"PERL\"); # false\n\nNot all \"(key,value)\"s are allowed to be changed. See also @Unicode::Collate::ChangeOK and\n@Unicode::Collate::ChangeNG.\n\nIn the scalar context, returns the modified collator (but it is not a clone from the\noriginal).\n\n$Collator->change(level => 2)->eq(\"perl\", \"PERL\"); # true\n\n$Collator->eq(\"perl\", \"PERL\"); # true; now max level is 2nd.\n\n$Collator->change(level => 4)->eq(\"perl\", \"PERL\"); # false\n\n\"$version = $Collator->version()\"\nReturns the version number (a string) of the Unicode Standard which the \"table\" file used by\nthe collator object is based on. If the table does not include a version line (starting with\n@version), returns \"unknown\".\n\nUCAVersion()\nReturns the revision number of UTS #10 this module consults, that should correspond with the\nDUCET incorporated.\n\nBaseUnicodeVersion()\nReturns the version number of UTS #10 this module consults, that should correspond with the\nDUCET incorporated.\n"
                }
            ]
        },
        "EXPORT": {
            "content": "No method will be exported.\n",
            "subsections": []
        },
        "INSTALL": {
            "content": "Though this module can be used without any \"table\" file, to use this module easily, it is\nrecommended to install a table file in the UCA format, by copying it under the directory <a\nplace in @INC>/Unicode/Collate.\n\nThe most preferable one is \"The Default Unicode Collation Element Table\" (aka DUCET), available\nfrom the Unicode Consortium's website:\n\nhttp://www.unicode.org/Public/UCA/\n\nhttp://www.unicode.org/Public/UCA/latest/allkeys.txt\n(latest version)\n\nIf DUCET is not installed, it is recommended to copy the file from\nhttp://www.unicode.org/Public/UCA/latest/allkeys.txt to <a place in\n@INC>/Unicode/Collate/allkeys.txt manually.\n",
            "subsections": []
        },
        "CAVEATS": {
            "content": "Normalization\nUse of the \"normalization\" parameter requires the Unicode::Normalize module (see\nUnicode::Normalize).\n\nIf you need not it (say, in the case when you need not handle any combining characters),\nassign \"(normalization => undef)\" explicitly.\n\n-- see 6.5 Avoiding Normalization, UTS #10.\n\nConformance Test\nThe Conformance Test for the UCA is available under <http://www.unicode.org/Public/UCA/>.\n\nFor CollationTestSHIFTED.txt, a collator via \"Unicode::Collate->new( )\" should be used; for\nCollationTestNONIGNORABLE.txt, a collator via \"Unicode::Collate->new(variable =>\n\"non-ignorable\", level => 3)\".\n\nIf \"UCAVersion\" is 26 or later, the \"identical\" level is preferred;\n\"Unicode::Collate->new(identical => 1)\" and \"Unicode::Collate->new(identical => 1,\"\n\"variable => \"non-ignorable\", level => 3)\" should be used.\n\nUnicode::Normalize is required to try The Conformance Test.\n\nEBCDIC-SUPPORT IS EXPERIMENTAL.\n\nAUTHOR, COPYRIGHT AND LICENSE\nThe Unicode::Collate module for perl was written by SADAHIRO Tomoyuki, <SADAHIRO@cpan.org>. This\nmodule is Copyright(C) 2001-2021, SADAHIRO Tomoyuki. Japan. All rights reserved.\n\nThis module is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n\nThe file Unicode/Collate/allkeys.txt was copied verbatim from\n<http://www.unicode.org/Public/UCA/13.0.0/allkeys.txt>. For this file, Copyright (c) 2020\nUnicode, Inc.; distributed under the Terms of Use in <http://www.unicode.org/termsofuse.html>\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Unicode Collation Algorithm - UTS #10\n<http://www.unicode.org/reports/tr10/>\n\nThe Default Unicode Collation Element Table (DUCET)\n<http://www.unicode.org/Public/UCA/latest/allkeys.txt>\n\nThe conformance test for the UCA\n<http://www.unicode.org/Public/UCA/latest/CollationTest.html>\n\n<http://www.unicode.org/Public/UCA/latest/CollationTest.zip>\n\nHangul Syllable Type\n<http://www.unicode.org/Public/UNIDATA/HangulSyllableType.txt>\n\nUnicode Normalization Forms - UAX #15\n<http://www.unicode.org/reports/tr15/>\n\nUnicode Locale Data Markup Language (LDML) - UTS #35\n<http://www.unicode.org/reports/tr35/>\n",
            "subsections": []
        }
    },
    "summary": "Unicode::Collate - Unicode Collation Algorithm",
    "flags": [],
    "examples": [],
    "see_also": []
}