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

📄 unicode::collate.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 3 页
字号:
.ie n .IP """$result = $Collator\->le($a, $b)""" 4.el .IP "\f(CW$result = $Collator\->le($a, $b)\fR" 4.IX Item "$result = $Collator->le($a, $b)".ie n .IP """$result = $Collator\->gt($a, $b)""" 4.el .IP "\f(CW$result = $Collator\->gt($a, $b)\fR" 4.IX Item "$result = $Collator->gt($a, $b)".ie n .IP """$result = $Collator\->ge($a, $b)""" 4.el .IP "\f(CW$result = $Collator\->ge($a, $b)\fR" 4.IX Item "$result = $Collator->ge($a, $b)".PDThey works like the same name operators as theirs..Sp.Vb 6\&   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..Ve.ie n .IP """$sortKey = $Collator\->getSortKey($string)""" 4.el .IP "\f(CW$sortKey = $Collator\->getSortKey($string)\fR" 4.IX Item "$sortKey = $Collator->getSortKey($string)"\&\-\- see 4.3 Form Sort Key, \s-1UTS\s0 #10..SpReturns a sort key..SpYou compare the sort keys using a binary comparisonand get the result of the comparison of the strings using \s-1UCA\s0..Sp.Vb 1\&   $Collator\->getSortKey($a) cmp $Collator\->getSortKey($b)\&\&      is equivalent to\&\&   $Collator\->cmp($a, $b).Ve.ie n .IP """$sortKeyForm = $Collator\->viewSortKey($string)""" 4.el .IP "\f(CW$sortKeyForm = $Collator\->viewSortKey($string)\fR" 4.IX Item "$sortKeyForm = $Collator->viewSortKey($string)"Converts a sorting key into its representation form.If \f(CW\*(C`UCA_Version\*(C'\fR is 8, the output is slightly different..Sp.Vb 3\&   use Unicode::Collate;\&   my $c = Unicode::Collate\->new();\&   print $c\->viewSortKey("Perl"),"\en";\&\&   # 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.Ve.Sh "Methods for Searching".IX Subsection "Methods for Searching"\&\fB\s-1DISCLAIMER:\s0\fR If \f(CW\*(C`preprocess\*(C'\fR or \f(CW\*(C`normalization\*(C'\fR parameter is truefor \f(CW$Collator\fR, calling these methods (\f(CW\*(C`index\*(C'\fR, \f(CW\*(C`match\*(C'\fR, \f(CW\*(C`gmatch\*(C'\fR,\&\f(CW\*(C`subst\*(C'\fR, \f(CW\*(C`gsubst\*(C'\fR) is croaked,as the position and the length might differfrom those on the specified string.(And \f(CW\*(C`rearrange\*(C'\fR and \f(CW\*(C`hangul_terminator\*(C'\fR parameters are neglected.).PPThe \f(CW\*(C`match\*(C'\fR, \f(CW\*(C`gmatch\*(C'\fR, \f(CW\*(C`subst\*(C'\fR, \f(CW\*(C`gsubst\*(C'\fR methods worklike \f(CW\*(C`m//\*(C'\fR, \f(CW\*(C`m//g\*(C'\fR, \f(CW\*(C`s///\*(C'\fR, \f(CW\*(C`s///g\*(C'\fR, respectively,but they are not aware of any pattern, but only a literal substring..ie n .IP """$position = $Collator\->index($string, $substring[, $position])""" 4.el .IP "\f(CW$position = $Collator\->index($string, $substring[, $position])\fR" 4.IX Item "$position = $Collator->index($string, $substring[, $position])".PD 0.ie n .IP """($position, $length) = $Collator\->index($string, $substring[, $position])""" 4.el .IP "\f(CW($position, $length) = $Collator\->index($string, $substring[, $position])\fR" 4.IX Item "($position, $length) = $Collator->index($string, $substring[, $position])".PDIf \f(CW$substring\fR matches a part of \f(CW$string\fR, 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..SpIf \f(CW$substring\fR does not match any part of \f(CW$string\fR,returns \f(CW\*(C`\-1\*(C'\fR in scalar context andan empty list in list context..Spe.g. you say.Sp.Vb 8\&  my $Collator = Unicode::Collate\->new( normalization => undef, level => 1 );\&                                     # (normalization => undef) is REQUIRED.\&  my $str = "Ich mu\*8 studieren Perl.";\&  my $sub = "MU\*:SS";\&  my $match;\&  if (my($pos,$len) = $Collator\->index($str, $sub)) {\&      $match = substr($str, $pos, $len);\&  }.Ve.Spand get \f(CW"mu\*8"\fR in \f(CW$match\fR since \f(CW"mu\*8"\fRis primary equal to \f(CW"MU\*:SS"\fR..ie n .IP """$match_ref = $Collator\->match($string, $substring)""" 4.el .IP "\f(CW$match_ref = $Collator\->match($string, $substring)\fR" 4.IX Item "$match_ref = $Collator->match($string, $substring)".PD 0.ie n .IP """($match)   = $Collator\->match($string, $substring)""" 4.el .IP "\f(CW($match)   = $Collator\->match($string, $substring)\fR" 4.IX Item "($match)   = $Collator->match($string, $substring)".PDIf \f(CW$substring\fR matches a part of \f(CW$string\fR, in scalar context, returns\&\fBa reference to\fR the first occurrence of the matching part(\f(CW$match_ref\fR is always true if matches,since every reference is \fBtrue\fR);in list context, returns the first occurrence of the matching part..SpIf \f(CW$substring\fR does not match any part of \f(CW$string\fR,returns \f(CW\*(C`undef\*(C'\fR in scalar context andan empty list in list context..Spe.g..Sp.Vb 5\&    if ($match_ref = $Collator\->match($str, $sub)) { # scalar context\&        print "matches [$$match_ref].\en";\&    } else {\&        print "doesn\*(Aqt match.\en";\&    }\&\&     or\&\&    if (($match) = $Collator\->match($str, $sub)) { # list context\&        print "matches [$match].\en";\&    } else {\&        print "doesn\*(Aqt match.\en";\&    }.Ve.ie n .IP """@match = $Collator\->gmatch($string, $substring)""" 4.el .IP "\f(CW@match = $Collator\->gmatch($string, $substring)\fR" 4.IX Item "@match = $Collator->gmatch($string, $substring)"If \f(CW$substring\fR matches a part of \f(CW$string\fR, returnsall the matching parts (or matching count in scalar context)..SpIf \f(CW$substring\fR does not match any part of \f(CW$string\fR,returns an empty list..ie n .IP """$count = $Collator\->subst($string, $substring, $replacement)""" 4.el .IP "\f(CW$count = $Collator\->subst($string, $substring, $replacement)\fR" 4.IX Item "$count = $Collator->subst($string, $substring, $replacement)"If \f(CW$substring\fR matches a part of \f(CW$string\fR,the first occurrence of the matching part is replaced by \f(CW$replacement\fR(\f(CW$string\fR is modified) and return \f(CW$count\fR (always equals to \f(CW1\fR)..Sp\&\f(CW$replacement\fR can be a \f(CW\*(C`CODEREF\*(C'\fR,taking the matching part as an argument,and returning a string to replace the matching part(a bit similar to \f(CW\*(C`s/(..)/$coderef\->($1)/e\*(C'\fR)..ie n .IP """$count = $Collator\->gsubst($string, $substring, $replacement)""" 4.el .IP "\f(CW$count = $Collator\->gsubst($string, $substring, $replacement)\fR" 4.IX Item "$count = $Collator->gsubst($string, $substring, $replacement)"If \f(CW$substring\fR matches a part of \f(CW$string\fR,all the occurrences of the matching part is replaced by \f(CW$replacement\fR(\f(CW$string\fR is modified) and return \f(CW$count\fR..Sp\&\f(CW$replacement\fR can be a \f(CW\*(C`CODEREF\*(C'\fR,taking the matching part as an argument,and returning a string to replace the matching part(a bit similar to \f(CW\*(C`s/(..)/$coderef\->($1)/eg\*(C'\fR)..Spe.g..Sp.Vb 4\&  my $Collator = Unicode::Collate\->new( normalization => undef, level => 1 );\&                                     # (normalization => undef) is REQUIRED.\&  my $str = "Camel donkey zebra came\ex{301}l CAMEL horse cAm\e0E\e0L...";\&  $Collator\->gsubst($str, "camel", sub { "<b>$_[0]</b>" });\&\&  # now $str is "<b>Camel</b> donkey zebra <b>came\ex{301}l</b> <b>CAMEL</b> horse <b>cAm\e0E\e0L</b>...";\&  # i.e., all the camels are made bold\-faced..Ve.Sh "Other Methods".IX Subsection "Other Methods".ie n .IP """%old_tailoring = $Collator\->change(%new_tailoring)""" 4.el .IP "\f(CW%old_tailoring = $Collator\->change(%new_tailoring)\fR" 4.IX Item "%old_tailoring = $Collator->change(%new_tailoring)"Change the value of specified keys and returns the changed part..Sp.Vb 1\&    $Collator = Unicode::Collate\->new(level => 4);\&\&    $Collator\->eq("perl", "PERL"); # false\&\&    %old = $Collator\->change(level => 2); # returns (level => 4).\&\&    $Collator\->eq("perl", "PERL"); # true\&\&    $Collator\->change(%old); # returns (level => 2).\&\&    $Collator\->eq("perl", "PERL"); # false.Ve.SpNot all \f(CW\*(C`(key,value)\*(C'\fRs are allowed to be changed.See also \f(CW@Unicode::Collate::ChangeOK\fR and \f(CW@Unicode::Collate::ChangeNG\fR..SpIn the scalar context, returns the modified collator(but it is \fBnot\fR a clone from the original)..Sp.Vb 1\&    $Collator\->change(level => 2)\->eq("perl", "PERL"); # true\&\&    $Collator\->eq("perl", "PERL"); # true; now max level is 2nd.\&\&    $Collator\->change(level => 4)\->eq("perl", "PERL"); # false.Ve.ie n .IP """$version = $Collator\->version()""" 4.el .IP "\f(CW$version = $Collator\->version()\fR" 4.IX Item "$version = $Collator->version()"Returns the version number (a string) of the Unicode Standardwhich the \f(CW\*(C`table\*(C'\fR file used by the collator object is based on.If the table does not include a version line (starting with \f(CW@version\fR),returns \f(CW"unknown"\fR..ie n .IP """UCA_Version()""" 4.el .IP "\f(CWUCA_Version()\fR" 4.IX Item "UCA_Version()"Returns the tracking version number of \s-1UTS\s0 #10 this module consults..ie n .IP """Base_Unicode_Version()""" 4.el .IP "\f(CWBase_Unicode_Version()\fR" 4.IX Item "Base_Unicode_Version()"Returns the version number of \s-1UTS\s0 #10 this module consults..SH "EXPORT".IX Header "EXPORT"No method will be exported..SH "INSTALL".IX Header "INSTALL"Though this module can be used without any \f(CW\*(C`table\*(C'\fR file,to use this module easily, it is recommended to install a table filein the \s-1UCA\s0 format, by copying it under the directory<a place in \f(CW@INC\fR>/Unicode/Collate..PPThe most preferable one is \*(L"The Default Unicode Collation Element Table\*(R"(aka \s-1DUCET\s0), available from the Unicode Consortium's website:.PP.Vb 1\&   http://www.unicode.org/Public/UCA/\&\&   http://www.unicode.org/Public/UCA/latest/allkeys.txt (latest version).Ve.PPIf \s-1DUCET\s0 is not installed, it is recommended to copy the filefrom http://www.unicode.org/Public/UCA/latest/allkeys.txtto <a place in \f(CW@INC\fR>/Unicode/Collate/allkeys.txtmanually..SH "CAVEATS".IX Header "CAVEATS".IP "Normalization" 4.IX Item "Normalization"Use of the \f(CW\*(C`normalization\*(C'\fR parameter requires the \fBUnicode::Normalize\fRmodule (see Unicode::Normalize)..SpIf you need not it (say, in the case when you need nothandle any combining characters),assign \f(CW\*(C`normalization => undef\*(C'\fR explicitly..Sp\&\-\- see 6.5 Avoiding Normalization, \s-1UTS\s0 #10..IP "Conformance Test" 4.IX Item "Conformance Test"The Conformance Test for the \s-1UCA\s0 is availableunder <http://www.unicode.org/Public/UCA/>..SpFor \fICollationTest_SHIFTED.txt\fR,a collator via \f(CW\*(C`Unicode::Collate\->new( )\*(C'\fR should be used;for \fICollationTest_NON_IGNORABLE.txt\fR, a collator via\&\f(CW\*(C`Unicode::Collate\->new(variable => "non\-ignorable", level => 3)\*(C'\fR..Sp\&\fBUnicode::Normalize is required to try The Conformance Test.\fR.SH "AUTHOR, COPYRIGHT AND LICENSE".IX Header "AUTHOR, COPYRIGHT AND LICENSE"The Unicode::Collate module for perl was written by \s-1SADAHIRO\s0 Tomoyuki,<SADAHIRO@cpan.org>. This module is Copyright(C) 2001\-2005,\&\s-1SADAHIRO\s0 Tomoyuki. Japan. All rights reserved..PPThis module is free software; you can redistribute it and/ormodify it under the same terms as Perl itself..PPThe file Unicode/Collate/allkeys.txt was copied directlyfrom <http://www.unicode.org/Public/UCA/4.1.0/allkeys.txt>.This file is Copyright (c) 1991\-2005 Unicode, Inc. All rights reserved.Distributed under the Terms of Use in <http://www.unicode.org/copyright.html>..SH "SEE ALSO".IX Header "SEE ALSO".IP "Unicode Collation Algorithm \- \s-1UTS\s0 #10" 4.IX Item "Unicode Collation Algorithm - UTS #10"<http://www.unicode.org/reports/tr10/>.IP "The Default Unicode Collation Element Table (\s-1DUCET\s0)" 4.IX Item "The Default Unicode Collation Element Table (DUCET)"<http://www.unicode.org/Public/UCA/latest/allkeys.txt>.IP "The conformance test for the \s-1UCA\s0" 4.IX Item "The conformance test for the UCA"<http://www.unicode.org/Public/UCA/latest/CollationTest.html>.Sp<http://www.unicode.org/Public/UCA/latest/CollationTest.zip>.IP "Hangul Syllable Type" 4.IX Item "Hangul Syllable Type"<http://www.unicode.org/Public/UNIDATA/HangulSyllableType.txt>.IP "Unicode Normalization Forms \- \s-1UAX\s0 #15" 4.IX Item "Unicode Normalization Forms - UAX #15"<http://www.unicode.org/reports/tr15/>

⌨️ 快捷键说明

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