⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 collate.pm

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 PM
📖 第 1 页 / 共 4 页
字号:
In DUCET v4.0.0, primary weight of C<C> is C<0E60>and that of C<D> is C<0E6D>. So setting primary weight of C<CH> to C<0E6A>(as a value between C<0E60> and C<0E6D>)makes ordering as C<C E<lt> CH E<lt> D>.Exactly speaking DUCET already has some characters between C<C> and C<D>:C<small capital C> (C<U+1D04>) with primary weight C<0E64>,C<c-hook/C-hook> (C<U+0188/U+0187>) with C<0E65>,and C<c-curl> (C<U+0255>) with C<0E69>.Then primary weight C<0E6A> for C<CH> makes C<CH>ordered between C<c-curl> and C<D>.=item hangul_terminator-- see 7.1.4 Trailing Weights, UTS #10.If a true value is given (non-zero but should be positive),it will be added as a terminator primary weight to the end ofevery standard Hangul syllable. Secondary and any higher weightsfor terminator are set to zero.If the value is false or C<hangul_terminator> key does not exist,insertion of terminator weights will not be performed.Boundaries of Hangul syllables are determinedaccording to conjoining Jamo behavior in F<the Unicode Standard>and F<HangulSyllableType.txt>.B<Implementation Note:>(1) For expansion mapping (Unicode character mappedto a sequence of collation elements), a terminator will not be addedbetween collation elements, even if Hangul syllable boundary exists there.Addition of terminator is restricted to the next positionto the last collation element.(2) Non-conjoining Hangul letters(Compatibility Jamo, halfwidth Jamo, and enclosed letters) are notautomatically terminated with a terminator primary weight.These characters may need terminator included in a collation elementtable beforehand.=item ignoreChar=item ignoreName-- see 3.2.2 Variable Weighting, UTS #10.Makes the entry in the table completely ignorable;i.e. as if the weights were zero at all level.Through C<ignoreChar>, any character matching C<qr/$ignoreChar/>will be ignored. Through C<ignoreName>, any character whose name(given in the C<table> file as a comment) matches C<qr/$ignoreName/>will be ignored.E.g. when 'a' and 'e' are ignorable,'element' is equal to 'lament' (or 'lmnt').=item katakana_before_hiragana-- see 7.3.1 Tertiary Weight Table, UTS #10.By default, hiragana is before katakana.If the parameter is made true, this is reversed.B<NOTE>: This parameter simplemindedly assumes that any hiragana/katakanadistinctions must occur in level 3, and their weights at level 3 must besame as those mentioned in 7.3.1, UTS #10.If you define your collation elements which violate this requirement,this parameter does not work validly.=item level-- see 4.3 Form Sort Key, UTS #10.Set the maximum level.Any higher levels than the specified one are ignored.  Level 1: alphabetic ordering  Level 2: diacritic ordering  Level 3: case ordering  Level 4: tie-breaking (e.g. in the case when variable is 'shifted')  ex.level => 2,If omitted, the maximum is the 4th.=item normalization-- see 4.1 Normalize, UTS #10.If specified, strings are normalized before preparation of sort keys(the normalization is executed after preprocess).A form name C<Unicode::Normalize::normalize()> accepts will be appliedas C<$normalization_form>.Acceptable names include C<'NFD'>, C<'NFC'>, C<'NFKD'>, and C<'NFKC'>.See C<Unicode::Normalize::normalize()> for detail.If omitted, C<'NFD'> is used.C<normalization> is performed after C<preprocess> (if defined).Furthermore, special values, C<undef> and C<"prenormalized">, can be used,though they are not concerned with C<Unicode::Normalize::normalize()>.If C<undef> (not a string C<"undef">) is passed explicitlyas the value for this key,any normalization is not carried out (this may make tailoring easierif any normalization is not desired). Under C<(normalization =E<gt> undef)>,only contiguous contractions are resolved;e.g. even if C<A-ring> (and C<A-ring-cedilla>) is ordered after C<Z>,C<A-cedilla-ring> would be primary equal to C<A>.In this point,C<(normalization =E<gt> undef, preprocess =E<gt> sub { NFD(shift) })>B<is not> equivalent to C<(normalization =E<gt> 'NFD')>.In the case of C<(normalization =E<gt> "prenormalized")>,any normalization is not performed, butnon-contiguous contractions with combining characters are performed.ThereforeC<(normalization =E<gt> 'prenormalized', preprocess =E<gt> sub { NFD(shift) })>B<is> equivalent to C<(normalization =E<gt> 'NFD')>.If source strings are finely prenormalized,C<(normalization =E<gt> 'prenormalized')> may save time for normalization.Except C<(normalization =E<gt> undef)>,B<Unicode::Normalize> is required (see also B<CAVEAT>).=item overrideCJK-- see 7.1 Derived Collation Elements, UTS #10.By default, CJK Unified Ideographs are ordered in Unicode codepoint orderbut C<CJK Unified Ideographs> (if C<UCA_Version> is 8 to 11, its range isC<U+4E00..U+9FA5>; if C<UCA_Version> is 14, its range is C<U+4E00..U+9FBB>)are lesser than C<CJK Unified Ideographs Extension> (its range isC<U+3400..U+4DB5> and C<U+20000..U+2A6D6>).Through C<overrideCJK>, ordering of CJK Unified Ideographs can be overrided.ex. CJK Unified Ideographs in the JIS code point order.  overrideCJK => sub {      my $u = shift;             # get a Unicode codepoint      my $b = pack('n', $u);     # to UTF-16BE      my $s = your_unicode_to_sjis_converter($b); # convert      my $n = unpack('n', $s);   # convert sjis to short      [ $n, 0x20, 0x2, $u ];     # return the collation element  },ex. ignores all CJK Unified Ideographs.  overrideCJK => sub {()}, # CODEREF returning empty list   # where ->eq("Pe\x{4E00}rl", "Perl") is true   # as U+4E00 is a CJK Unified Ideograph and to be ignorable.If C<undef> is passed explicitly as the value for this key,weights for CJK Unified Ideographs are treated as undefined.But assignment of weight for CJK Unified Ideographsin table or C<entry> is still valid.=item overrideHangul-- see 7.1 Derived Collation Elements, UTS #10.By default, Hangul Syllables are decomposed into Hangul Jamo,even if C<(normalization =E<gt> undef)>.But the mapping of Hangul Syllables may be overrided.This parameter works like C<overrideCJK>, so see there for examples.If you want to override the mapping of Hangul Syllables,NFD, NFKD, and FCD are not appropriate,since they will decompose Hangul Syllables before overriding.If C<undef> is passed explicitly as the value for this key,weight for Hangul Syllables is treated as undefinedwithout decomposition into Hangul Jamo.But definition of weight for Hangul Syllablesin table or C<entry> is still valid.=item preprocess-- see 5.1 Preprocessing, UTS #10.If specified, the coderef is used to preprocessbefore the formation of sort keys.ex. dropping English articles, such as "a" or "the".Then, "the pen" is before "a pencil".     preprocess => sub {           my $str = shift;           $str =~ s/\b(?:an?|the)\s+//gi;           return $str;        },C<preprocess> is performed before C<normalization> (if defined).=item rearrange-- see 3.1.3 Rearrangement, UTS #10.Characters that are not coded in logical order and to be rearranged.If C<UCA_Version> is equal to or lesser than 11, default is:    rearrange => [ 0x0E40..0x0E44, 0x0EC0..0x0EC4 ],If you want to disallow any rearrangement, pass C<undef> or C<[]>(a reference to empty list) as the value for this key.If C<UCA_Version> is equal to 14, default is C<[]> (i.e. no rearrangement).B<According to the version 9 of UCA, this parameter shall not be used;but it is not warned at present.>=item table-- see 3.2 Default Unicode Collation Element Table, UTS #10.You can use another collation element table if desired.The table file should locate in the F<Unicode/Collate> directoryon C<@INC>. Say, if the filename is F<Foo.txt>,the table file is searched as F<Unicode/Collate/Foo.txt> in C<@INC>.By default, F<allkeys.txt> (as the filename of DUCET) is used.If you will prepare your own table file, any name other than F<allkeys.txt>may be better to avoid namespace conflict.If C<undef> is passed explicitly as the value for this key,no file is read (but you can define collation elements via C<entry>).A typical way to define a collation element tablewithout any file of table:   $onlyABC = Unicode::Collate->new(       table => undef,       entry => << 'ENTRIES',0061 ; [.0101.0020.0002.0061] # LATIN SMALL LETTER A0041 ; [.0101.0020.0008.0041] # LATIN CAPITAL LETTER A0062 ; [.0102.0020.0002.0062] # LATIN SMALL LETTER B0042 ; [.0102.0020.0008.0042] # LATIN CAPITAL LETTER B0063 ; [.0103.0020.0002.0063] # LATIN SMALL LETTER C0043 ; [.0103.0020.0008.0043] # LATIN CAPITAL LETTER CENTRIES    );If C<ignoreName> or C<undefName> is used, character names should bespecified as a comment (following C<#>) on each line.=item undefChar=item undefName-- see 6.3.4 Reducing the Repertoire, UTS #10.Undefines the collation element as if it were unassigned in the table.This reduces the size of the table.If an unassigned character appears in the string to be collated,the sort key is made from its codepointas a single-character collation element,as it is greater than any other assigned collation elements(in the codepoint order among the unassigned characters).But, it'd be better to ignore charactersunfamiliar to you and maybe never used.Through C<undefChar>, any character matching C<qr/$undefChar/>will be undefined. Through C<undefName>, any character whose name(given in the C<table> file as a comment) matches C<qr/$undefName/>will be undefined.ex. Collation weights for beyond-BMP characters are not stored in object:    undefChar => qr/[^\0-\x{fffd}]/,=item upper_before_lower-- see 6.6 Case Comparisons, UTS #10.By default, lowercase is before uppercase.If the parameter is made true, this is reversed.B<NOTE>: This parameter simplemindedly assumes that any lowercase/uppercasedistinctions must occur in level 3, and their weights at level 3 must besame as those mentioned in 7.3.1, UTS #10.If you define your collation elements which differs from this requirement,this parameter doesn't work validly.=item variable-- see 3.2.2 Variable Weighting, UTS #10.This key allows to variable weighting for variable collation elements,which are marked with an ASTERISK in the table(NOTE: Many punction marks and symbols are variable in F<allkeys.txt>).   variable => 'blanked', 'non-ignorable', 'shifted', or 'shift-trimmed'.These names are case-insensitive.By default (if specification is omitted), 'shifted' is adopted.   'Blanked'        Variable elements are made ignorable at levels 1 through 3;                    considered at the 4th level.   'Non-Ignorable'  Variable elements are not reset to ignorable.   'Shifted'        Variable elements are made ignorable at levels 1 through 3                    their level 4 weight is replaced by the old level 1 weight.                    Level 4 weight for Non-Variable elements is 0xFFFF.   'Shift-Trimmed'  Same as 'shifted', but all FFFF's at the 4th level                    are trimmed.=back=head2 Methods for Collation=over 4=item C<@sorted = $Collator-E<gt>sort(@not_sorted)>Sorts a list of strings.=item C<$result = $Collator-E<gt>cmp($a, $b)>Returns 1 (when C<$a> is greater than C<$b>)or 0 (when C<$a> is equal to C<$b>)or -1 (when C<$a> is lesser than C<$b>).=item C<$result = $Collator-E<gt>eq($a, $b)>=item C<$result = $Collator-E<gt>ne($a, $b)>=item C<$result = $Collator-E<gt>lt($a, $b)>=item C<$result = $Collator-E<gt>le($a, $b)>=item C<$result = $Collator-E<gt>gt($a, $b)>=item C<$result = $Collator-E<gt>ge($a, $b)>They works like the same name operators as theirs.   eq : whether $a is equal to $b.   ne : whether $a is not equal to $b.   lt : whether $a is lesser than $b.   le : whether $a is lesser than $b or equal to $b.   gt : whether $a is greater than $b.   ge : whether $a is greater than $b or equal to $b.=item C<$sortKey = $Collator-E<gt>getSortKey($string)>-- see 4.3 Form Sort Key, UTS #10.Returns a sort key.You compare the sort keys using a binary comparisonand get the result of the comparison of the strings using UCA.   $Collator->getSortKey($a) cmp $Collator->getSortKey($b)      is equivalent to   $Collator->cmp($a, $b)=item C<$sortKeyForm = $Collator-E<gt>viewSortKey($string)>Converts a sorting key into its representation form.If C<UCA_Version> is 8, the output is slightly different.   use Unicode::Collate;   my $c = Unicode::Collate->new();   print $c->viewSortKey("Perl"),"\n";   # output:   # [0B67 0A65 0B7F 0B03 | 0020 0020 0020 0020 | 0008 0002 0002 0002 | FFFF FFFF FFFF FFFF]   #  Level 1               Level 2               Level 3               Level 4=back=head2 Methods for SearchingB<DISCLAIMER:> If C<preprocess> or C<normalization> parameter is truefor C<$Collator>, calling these methods (C<index>, C<match>, C<gmatch>,C<subst>, C<gsubst>) is croaked,as the position and the length might differfrom those on the specified string.(And C<rearrange> and C<hangul_terminator> parameters are neglected.)The C<match>, C<gmatch>, C<subst>, C<gsubst> methods worklike C<m//>, C<m//g>, C<s///>, C<s///g>, respectively,but they are not aware of any pattern, but only a literal substring.=over 4=item C<$position = $Collator-E<gt>index($string, $substring[, $position])>=item C<($position, $length) = $Collator-E<gt>index($string, $substring[, $position])>If C<$substring> matches a part of C<$string>, returnsthe position of the first occurrence of the matching part in scalar context;in list context, returns a two-element list ofthe position and the length of the matching part.If C<$substring> does not match any part of C<$string>,returns C<-1> in scalar context andan empty list in list context.e.g. you say  my $Collator = Unicode::Collate->new( normalization => undef, level => 1 );                                     # (normalization => undef) is REQUIRED.  my $str = "Ich mu

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -