Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | .\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13 |
2 | .\" | |
3 | .\" Standard preamble: | |
4 | .\" ======================================================================== | |
5 | .de Sh \" Subsection heading | |
6 | .br | |
7 | .if t .Sp | |
8 | .ne 5 | |
9 | .PP | |
10 | \fB\\$1\fR | |
11 | .PP | |
12 | .. | |
13 | .de Sp \" Vertical space (when we can't use .PP) | |
14 | .if t .sp .5v | |
15 | .if n .sp | |
16 | .. | |
17 | .de Vb \" Begin verbatim text | |
18 | .ft CW | |
19 | .nf | |
20 | .ne \\$1 | |
21 | .. | |
22 | .de Ve \" End verbatim text | |
23 | .ft R | |
24 | .fi | |
25 | .. | |
26 | .\" Set up some character translations and predefined strings. \*(-- will | |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a | |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to | |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' | |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. | |
32 | .tr \(*W-|\(bv\*(Tr | |
33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' | |
34 | .ie n \{\ | |
35 | . ds -- \(*W- | |
36 | . ds PI pi | |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |
39 | . ds L" "" | |
40 | . ds R" "" | |
41 | . ds C` "" | |
42 | . ds C' "" | |
43 | 'br\} | |
44 | .el\{\ | |
45 | . ds -- \|\(em\| | |
46 | . ds PI \(*p | |
47 | . ds L" `` | |
48 | . ds R" '' | |
49 | 'br\} | |
50 | .\" | |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for | |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index | |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the | |
54 | .\" output yourself in some meaningful fashion. | |
55 | .if \nF \{\ | |
56 | . de IX | |
57 | . tm Index:\\$1\t\\n%\t"\\$2" | |
58 | .. | |
59 | . nr % 0 | |
60 | . rr F | |
61 | .\} | |
62 | .\" | |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes | |
64 | .\" way too many mistakes in technical documents. | |
65 | .hy 0 | |
66 | .if n .na | |
67 | .\" | |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). | |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. | |
70 | . \" fudge factors for nroff and troff | |
71 | .if n \{\ | |
72 | . ds #H 0 | |
73 | . ds #V .8m | |
74 | . ds #F .3m | |
75 | . ds #[ \f1 | |
76 | . ds #] \fP | |
77 | .\} | |
78 | .if t \{\ | |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) | |
80 | . ds #V .6m | |
81 | . ds #F 0 | |
82 | . ds #[ \& | |
83 | . ds #] \& | |
84 | .\} | |
85 | . \" simple accents for nroff and troff | |
86 | .if n \{\ | |
87 | . ds ' \& | |
88 | . ds ` \& | |
89 | . ds ^ \& | |
90 | . ds , \& | |
91 | . ds ~ ~ | |
92 | . ds / | |
93 | .\} | |
94 | .if t \{\ | |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" | |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |
101 | .\} | |
102 | . \" troff and (daisy-wheel) nroff accents | |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' | |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |
110 | .ds ae a\h'-(\w'a'u*4/10)'e | |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E | |
112 | . \" corrections for vroff | |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' | |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |
115 | . \" for low resolution devices (crt and lpr) | |
116 | .if \n(.H>23 .if \n(.V>19 \ | |
117 | \{\ | |
118 | . ds : e | |
119 | . ds 8 ss | |
120 | . ds o a | |
121 | . ds d- d\h'-1'\(ga | |
122 | . ds D- D\h'-1'\(hy | |
123 | . ds th \o'bp' | |
124 | . ds Th \o'LP' | |
125 | . ds ae ae | |
126 | . ds Ae AE | |
127 | .\} | |
128 | .rm #[ #] #H #V #F C | |
129 | .\" ======================================================================== | |
130 | .\" | |
131 | .IX Title "Unicode::Collate 3" | |
132 | .TH Unicode::Collate 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide" | |
133 | .SH "NAME" | |
134 | Unicode::Collate \- Unicode Collation Algorithm | |
135 | .SH "SYNOPSIS" | |
136 | .IX Header "SYNOPSIS" | |
137 | .Vb 1 | |
138 | \& use Unicode::Collate; | |
139 | .Ve | |
140 | .PP | |
141 | .Vb 2 | |
142 | \& #construct | |
143 | \& $Collator = Unicode::Collate->new(%tailoring); | |
144 | .Ve | |
145 | .PP | |
146 | .Vb 2 | |
147 | \& #sort | |
148 | \& @sorted = $Collator->sort(@not_sorted); | |
149 | .Ve | |
150 | .PP | |
151 | .Vb 2 | |
152 | \& #compare | |
153 | \& $result = $Collator->cmp($a, $b); # returns 1, 0, or -1. | |
154 | .Ve | |
155 | .SH "DESCRIPTION" | |
156 | .IX Header "DESCRIPTION" | |
157 | .Sh "Constructor and Tailoring" | |
158 | .IX Subsection "Constructor and Tailoring" | |
159 | The \f(CW\*(C`new\*(C'\fR method returns a collator object. | |
160 | .PP | |
161 | .Vb 20 | |
162 | \& $Collator = Unicode::Collate->new( | |
163 | \& alternate => $alternate, | |
164 | \& backwards => $levelNumber, # or \e@levelNumbers | |
165 | \& entry => $element, | |
166 | \& normalization => $normalization_form, | |
167 | \& ignoreName => qr/$ignoreName/, | |
168 | \& ignoreChar => qr/$ignoreChar/, | |
169 | \& katakana_before_hiragana => $bool, | |
170 | \& level => $collationLevel, | |
171 | \& overrideCJK => \e&overrideCJK, | |
172 | \& overrideHangul => \e&overrideHangul, | |
173 | \& preprocess => \e&preprocess, | |
174 | \& rearrange => \e@charList, | |
175 | \& table => $filename, | |
176 | \& undefName => qr/$undefName/, | |
177 | \& undefChar => qr/$undefChar/, | |
178 | \& upper_before_lower => $bool, | |
179 | \& ); | |
180 | \& # if %tailoring is false (i.e. empty), | |
181 | \& # $Collator should do the default collation. | |
182 | .Ve | |
183 | .IP "alternate" 4 | |
184 | .IX Item "alternate" | |
185 | \&\-\- see 3.2.2 Alternate Weighting, \s-1UTR\s0 #10. | |
186 | .Sp | |
187 | This key allows to alternate weighting for variable collation elements, | |
188 | which are marked with an \s-1ASTERISK\s0 in the table | |
189 | (\s-1NOTE:\s0 Many punction marks and symbols are variable in \fIallkeys.txt\fR). | |
190 | .Sp | |
191 | .Vb 1 | |
192 | \& alternate => 'blanked', 'non-ignorable', 'shifted', or 'shift-trimmed'. | |
193 | .Ve | |
194 | .Sp | |
195 | These names are case\-insensitive. | |
196 | By default (if specification is omitted), 'shifted' is adopted. | |
197 | .Sp | |
198 | .Vb 2 | |
199 | \& 'Blanked' Variable elements are ignorable at levels 1 through 3; | |
200 | \& considered at the 4th level. | |
201 | .Ve | |
202 | .Sp | |
203 | .Vb 1 | |
204 | \& 'Non-ignorable' Variable elements are not reset to ignorable. | |
205 | .Ve | |
206 | .Sp | |
207 | .Vb 3 | |
208 | \& 'Shifted' Variable elements are ignorable at levels 1 through 3 | |
209 | \& their level 4 weight is replaced by the old level 1 weight. | |
210 | \& Level 4 weight for Non-Variable elements is 0xFFFF. | |
211 | .Ve | |
212 | .Sp | |
213 | .Vb 2 | |
214 | \& 'Shift-Trimmed' Same as 'shifted', but all FFFF's at the 4th level | |
215 | \& are trimmed. | |
216 | .Ve | |
217 | .IP "backwards" 4 | |
218 | .IX Item "backwards" | |
219 | \&\-\- see 3.1.2 French Accents, \s-1UTR\s0 #10. | |
220 | .Sp | |
221 | .Vb 1 | |
222 | \& backwards => $levelNumber or \e@levelNumbers | |
223 | .Ve | |
224 | .Sp | |
225 | Weights in reverse order; ex. level 2 (diacritic ordering) in French. | |
226 | If omitted, forwards at all the levels. | |
227 | .IP "entry" 4 | |
228 | .IX Item "entry" | |
229 | \&\-\- see 3.1 Linguistic Features; 3.2.1 File Format, \s-1UTR\s0 #10. | |
230 | .Sp | |
231 | Overrides a default order or defines additional collation elements | |
232 | .Sp | |
233 | .Vb 5 | |
234 | \& entry => <<'ENTRIES', # use the UCA file format | |
235 | \&00E6 ; [.0861.0020.0002.00E6] [.08B1.0020.0002.00E6] # ligature <ae> as <a><e> | |
236 | \&0063 0068 ; [.0893.0020.0002.0063] # "ch" in traditional Spanish | |
237 | \&0043 0068 ; [.0893.0020.0008.0043] # "Ch" in traditional Spanish | |
238 | \&ENTRIES | |
239 | .Ve | |
240 | .IP "ignoreName" 4 | |
241 | .IX Item "ignoreName" | |
242 | .PD 0 | |
243 | .IP "ignoreChar" 4 | |
244 | .IX Item "ignoreChar" | |
245 | .PD | |
246 | \&\-\- see Completely Ignorable, 3.2.2 Alternate Weighting, \s-1UTR\s0 #10. | |
247 | .Sp | |
248 | Makes the entry in the table ignorable. | |
249 | If a collation element is ignorable, | |
250 | it is ignored as if the element had been deleted from there. | |
251 | .Sp | |
252 | E.g. when 'a' and 'e' are ignorable, | |
253 | \&'element' is equal to 'lament' (or 'lmnt'). | |
254 | .IP "level" 4 | |
255 | .IX Item "level" | |
256 | \&\-\- see 4.3 Form a sort key for each string, \s-1UTR\s0 #10. | |
257 | .Sp | |
258 | Set the maximum level. | |
259 | Any higher levels than the specified one are ignored. | |
260 | .Sp | |
261 | .Vb 4 | |
262 | \& Level 1: alphabetic ordering | |
263 | \& Level 2: diacritic ordering | |
264 | \& Level 3: case ordering | |
265 | \& Level 4: tie-breaking (e.g. in the case when alternate is 'shifted') | |
266 | .Ve | |
267 | .Sp | |
268 | .Vb 1 | |
269 | \& ex.level => 2, | |
270 | .Ve | |
271 | .Sp | |
272 | If omitted, the maximum is the 4th. | |
273 | .IP "normalization" 4 | |
274 | .IX Item "normalization" | |
275 | \&\-\- see 4.1 Normalize each input string, \s-1UTR\s0 #10. | |
276 | .Sp | |
277 | If specified, strings are normalized before preparation of sort keys | |
278 | (the normalization is executed after preprocess). | |
279 | .Sp | |
280 | As a form name, one of the following names must be used. | |
281 | .Sp | |
282 | .Vb 4 | |
283 | \& 'C' or 'NFC' for Normalization Form C | |
284 | \& 'D' or 'NFD' for Normalization Form D | |
285 | \& 'KC' or 'NFKC' for Normalization Form KC | |
286 | \& 'KD' or 'NFKD' for Normalization Form KD | |
287 | .Ve | |
288 | .Sp | |
289 | If omitted, the string is put into Normalization Form D. | |
290 | .Sp | |
291 | If \f(CW\*(C`undef\*(C'\fR is passed explicitly as the value for this key, | |
292 | any normalization is not carried out (this may make tailoring easier | |
293 | if any normalization is not desired). | |
294 | .Sp | |
295 | see \fB\s-1CAVEAT\s0\fR. | |
296 | .IP "overrideCJK" 4 | |
297 | .IX Item "overrideCJK" | |
298 | \&\-\- see 7.1 Derived Collation Elements, \s-1UTR\s0 #10. | |
299 | .Sp | |
300 | By default, mapping of \s-1CJK\s0 Unified Ideographs | |
301 | uses the Unicode codepoint order. | |
302 | But the mapping of \s-1CJK\s0 Unified Ideographs may be overrided. | |
303 | .Sp | |
304 | ex. \s-1CJK\s0 Unified Ideographs in the \s-1JIS\s0 code point order. | |
305 | .Sp | |
306 | .Vb 7 | |
307 | \& overrideCJK => sub { | |
308 | \& my $u = shift; # get a Unicode codepoint | |
309 | \& my $b = pack('n', $u); # to UTF-16BE | |
310 | \& my $s = your_unicode_to_sjis_converter($b); # convert | |
311 | \& my $n = unpack('n', $s); # convert sjis to short | |
312 | \& [ $n, 0x20, 0x2, $u ]; # return the collation element | |
313 | \& }, | |
314 | .Ve | |
315 | .Sp | |
316 | ex. ignores all \s-1CJK\s0 Unified Ideographs. | |
317 | .Sp | |
318 | .Vb 1 | |
319 | \& overrideCJK => sub {()}, # CODEREF returning empty list | |
320 | .Ve | |
321 | .Sp | |
322 | .Vb 2 | |
323 | \& # where ->eq("Pe\ex{4E00}rl", "Perl") is true | |
324 | \& # as U+4E00 is a CJK Unified Ideograph and to be ignorable. | |
325 | .Ve | |
326 | .Sp | |
327 | If \f(CW\*(C`undef\*(C'\fR is passed explicitly as the value for this key, | |
328 | weights for \s-1CJK\s0 Unified Ideographs are treated as undefined. | |
329 | But assignment of weight for \s-1CJK\s0 Unified Ideographs | |
330 | in table or entry is still valid. | |
331 | .IP "overrideHangul" 4 | |
332 | .IX Item "overrideHangul" | |
333 | \&\-\- see 7.1 Derived Collation Elements, \s-1UTR\s0 #10. | |
334 | .Sp | |
335 | By default, Hangul Syllables are decomposed into Hangul Jamo. | |
336 | But the mapping of Hangul Syllables may be overrided. | |
337 | .Sp | |
338 | This tag works like overrideCJK, so see there for examples. | |
339 | .Sp | |
340 | If you want to override the mapping of Hangul Syllables, | |
341 | the Normalization Forms D and \s-1KD\s0 are not appropriate | |
342 | (they will be decomposed before overriding). | |
343 | .Sp | |
344 | If \f(CW\*(C`undef\*(C'\fR is passed explicitly as the value for this key, | |
345 | weight for Hangul Syllables is treated as undefined | |
346 | without decomposition into Hangul Jamo. | |
347 | But definition of weight for Hangul Syllables | |
348 | in table or entry is still valid. | |
349 | .IP "preprocess" 4 | |
350 | .IX Item "preprocess" | |
351 | \&\-\- see 5.1 Preprocessing, \s-1UTR\s0 #10. | |
352 | .Sp | |
353 | If specified, the coderef is used to preprocess | |
354 | before the formation of sort keys. | |
355 | .Sp | |
356 | ex. dropping English articles, such as \*(L"a\*(R" or \*(L"the\*(R". | |
357 | Then, \*(L"the pen\*(R" is before \*(L"a pencil\*(R". | |
358 | .Sp | |
359 | .Vb 5 | |
360 | \& preprocess => sub { | |
361 | \& my $str = shift; | |
362 | \& $str =~ s/\eb(?:an?|the)\es+//gi; | |
363 | \& $str; | |
364 | \& }, | |
365 | .Ve | |
366 | .IP "rearrange" 4 | |
367 | .IX Item "rearrange" | |
368 | \&\-\- see 3.1.3 Rearrangement, \s-1UTR\s0 #10. | |
369 | .Sp | |
370 | Characters that are not coded in logical order and to be rearranged. | |
371 | By default, | |
372 | .Sp | |
373 | .Vb 1 | |
374 | \& rearrange => [ 0x0E40..0x0E44, 0x0EC0..0x0EC4 ], | |
375 | .Ve | |
376 | .Sp | |
377 | If you want to disallow any rearrangement, | |
378 | pass \f(CW\*(C`undef\*(C'\fR or \f(CW\*(C`[]\*(C'\fR (a reference to an empty list) | |
379 | as the value for this key. | |
380 | .IP "table" 4 | |
381 | .IX Item "table" | |
382 | \&\-\- see 3.2 Default Unicode Collation Element Table, \s-1UTR\s0 #10. | |
383 | .Sp | |
384 | You can use another element table if desired. | |
385 | The table file must be in your \f(CW\*(C`lib/Unicode/Collate\*(C'\fR directory. | |
386 | .Sp | |
387 | By default, the file \f(CW\*(C`lib/Unicode/Collate/allkeys.txt\*(C'\fR is used. | |
388 | .Sp | |
389 | If \f(CW\*(C`undef\*(C'\fR is passed explicitly as the value for this key, | |
390 | no file is read (but you can define collation elements via entry). | |
391 | .Sp | |
392 | A typical way to define a collation element table | |
393 | without any file of table: | |
394 | .Sp | |
395 | .Vb 11 | |
396 | \& $onlyABC = Unicode::Collate->new( | |
397 | \& table => undef, | |
398 | \& entry => << 'ENTRIES', | |
399 | \&0061 ; [.0101.0020.0002.0061] # LATIN SMALL LETTER A | |
400 | \&0041 ; [.0101.0020.0008.0041] # LATIN CAPITAL LETTER A | |
401 | \&0062 ; [.0102.0020.0002.0062] # LATIN SMALL LETTER B | |
402 | \&0042 ; [.0102.0020.0008.0042] # LATIN CAPITAL LETTER B | |
403 | \&0063 ; [.0103.0020.0002.0063] # LATIN SMALL LETTER C | |
404 | \&0043 ; [.0103.0020.0008.0043] # LATIN CAPITAL LETTER C | |
405 | \&ENTRIES | |
406 | \& ); | |
407 | .Ve | |
408 | .IP "undefName" 4 | |
409 | .IX Item "undefName" | |
410 | .PD 0 | |
411 | .IP "undefChar" 4 | |
412 | .IX Item "undefChar" | |
413 | .PD | |
414 | \&\-\- see 6.3.4 Reducing the Repertoire, \s-1UTR\s0 #10. | |
415 | .Sp | |
416 | Undefines the collation element as if it were unassigned in the table. | |
417 | This reduces the size of the table. | |
418 | If an unassigned character appears in the string to be collated, | |
419 | the sort key is made from its codepoint | |
420 | as a single-character collation element, | |
421 | as it is greater than any other assigned collation elements | |
422 | (in the codepoint order among the unassigned characters). | |
423 | But, it'd be better to ignore characters | |
424 | unfamiliar to you and maybe never used. | |
425 | .IP "katakana_before_hiragana" 4 | |
426 | .IX Item "katakana_before_hiragana" | |
427 | .PD 0 | |
428 | .IP "upper_before_lower" 4 | |
429 | .IX Item "upper_before_lower" | |
430 | .PD | |
431 | \&\-\- see 6.6 Case Comparisons; 7.3.1 Tertiary Weight Table, \s-1UTR\s0 #10. | |
432 | .Sp | |
433 | By default, lowercase is before uppercase | |
434 | and hiragana is before katakana. | |
435 | .Sp | |
436 | If the tag is made true, this is reversed. | |
437 | .Sp | |
438 | \&\fB\s-1NOTE\s0\fR: These tags simplemindedly assume | |
439 | any lowercase/uppercase or hiragana/katakana distinctions | |
440 | should occur in level 3, and their weights at level 3 | |
441 | should be same as those mentioned in 7.3.1, \s-1UTR\s0 #10. | |
442 | If you define your collation elements which violates this, | |
443 | these tags doesn't work validly. | |
444 | .Sh "Methods for Collation" | |
445 | .IX Subsection "Methods for Collation" | |
446 | .ie n .IP """@sorted = $Collator\->sort(@not_sorted)""" 4 | |
447 | .el .IP "\f(CW@sorted = $Collator\->sort(@not_sorted)\fR" 4 | |
448 | .IX Item "@sorted = $Collator->sort(@not_sorted)" | |
449 | Sorts a list of strings. | |
450 | .ie n .IP """$result = $Collator\->cmp($a, $b)""" 4 | |
451 | .el .IP "\f(CW$result = $Collator\->cmp($a, $b)\fR" 4 | |
452 | .IX Item "$result = $Collator->cmp($a, $b)" | |
453 | Returns 1 (when \f(CW$a\fR is greater than \f(CW$b\fR) | |
454 | or 0 (when \f(CW$a\fR is equal to \f(CW$b\fR) | |
455 | or \-1 (when \f(CW$a\fR is lesser than \f(CW$b\fR). | |
456 | .ie n .IP """$result = $Collator\->eq($a, $b)""" 4 | |
457 | .el .IP "\f(CW$result = $Collator\->eq($a, $b)\fR" 4 | |
458 | .IX Item "$result = $Collator->eq($a, $b)" | |
459 | .PD 0 | |
460 | .ie n .IP """$result = $Collator\->ne($a, $b)""" 4 | |
461 | .el .IP "\f(CW$result = $Collator\->ne($a, $b)\fR" 4 | |
462 | .IX Item "$result = $Collator->ne($a, $b)" | |
463 | .ie n .IP """$result = $Collator\->lt($a, $b)""" 4 | |
464 | .el .IP "\f(CW$result = $Collator\->lt($a, $b)\fR" 4 | |
465 | .IX Item "$result = $Collator->lt($a, $b)" | |
466 | .ie n .IP """$result = $Collator\->le($a, $b)""" 4 | |
467 | .el .IP "\f(CW$result = $Collator\->le($a, $b)\fR" 4 | |
468 | .IX Item "$result = $Collator->le($a, $b)" | |
469 | .ie n .IP """$result = $Collator\->gt($a, $b)""" 4 | |
470 | .el .IP "\f(CW$result = $Collator\->gt($a, $b)\fR" 4 | |
471 | .IX Item "$result = $Collator->gt($a, $b)" | |
472 | .ie n .IP """$result = $Collator\->ge($a, $b)""" 4 | |
473 | .el .IP "\f(CW$result = $Collator\->ge($a, $b)\fR" 4 | |
474 | .IX Item "$result = $Collator->ge($a, $b)" | |
475 | .PD | |
476 | They works like the same name operators as theirs. | |
477 | .Sp | |
478 | .Vb 6 | |
479 | \& eq : whether $a is equal to $b. | |
480 | \& ne : whether $a is not equal to $b. | |
481 | \& lt : whether $a is lesser than $b. | |
482 | \& le : whether $a is lesser than $b or equal to $b. | |
483 | \& gt : whether $a is greater than $b. | |
484 | \& ge : whether $a is greater than $b or equal to $b. | |
485 | .Ve | |
486 | .ie n .IP """$sortKey = $Collator\->getSortKey($string)""" 4 | |
487 | .el .IP "\f(CW$sortKey = $Collator\->getSortKey($string)\fR" 4 | |
488 | .IX Item "$sortKey = $Collator->getSortKey($string)" | |
489 | \&\-\- see 4.3 Form a sort key for each string, \s-1UTR\s0 #10. | |
490 | .Sp | |
491 | Returns a sort key. | |
492 | .Sp | |
493 | You compare the sort keys using a binary comparison | |
494 | and get the result of the comparison of the strings using \s-1UCA\s0. | |
495 | .Sp | |
496 | .Vb 1 | |
497 | \& $Collator->getSortKey($a) cmp $Collator->getSortKey($b) | |
498 | .Ve | |
499 | .Sp | |
500 | .Vb 1 | |
501 | \& is equivalent to | |
502 | .Ve | |
503 | .Sp | |
504 | .Vb 1 | |
505 | \& $Collator->cmp($a, $b) | |
506 | .Ve | |
507 | .ie n .IP """$sortKeyForm = $Collator\->viewSortKey($string)""" 4 | |
508 | .el .IP "\f(CW$sortKeyForm = $Collator\->viewSortKey($string)\fR" 4 | |
509 | .IX Item "$sortKeyForm = $Collator->viewSortKey($string)" | |
510 | Returns a string formalized to display a sort key. | |
511 | Weights are enclosed with \f(CW'['\fR and \f(CW']'\fR | |
512 | and level boundaries are denoted by \f(CW'|'\fR. | |
513 | .Sp | |
514 | .Vb 3 | |
515 | \& use Unicode::Collate; | |
516 | \& my $c = Unicode::Collate->new(); | |
517 | \& print $c->viewSortKey("Perl"),"\en"; | |
518 | .Ve | |
519 | .Sp | |
520 | .Vb 3 | |
521 | \& # output: | |
522 | \& # [09B3 08B1 09CB 094F|0020 0020 0020 0020|0008 0002 0002 0002|FFFF FFFF FFFF FFFF] | |
523 | \& # Level 1 Level 2 Level 3 Level 4 | |
524 | .Ve | |
525 | .ie n .IP """$position = $Collator\->index($string, $substring)""" 4 | |
526 | .el .IP "\f(CW$position = $Collator\->index($string, $substring)\fR" 4 | |
527 | .IX Item "$position = $Collator->index($string, $substring)" | |
528 | .PD 0 | |
529 | .ie n .IP """($position, $length) = $Collator\->index($string, $substring)""" 4 | |
530 | .el .IP "\f(CW($position, $length) = $Collator\->index($string, $substring)\fR" 4 | |
531 | .IX Item "($position, $length) = $Collator->index($string, $substring)" | |
532 | .PD | |
533 | \&\-\- see 6.8 Searching, \s-1UTR\s0 #10. | |
534 | .Sp | |
535 | If \f(CW$substring\fR matches a part of \f(CW$string\fR, returns | |
536 | the position of the first occurrence of the matching part in scalar context; | |
537 | in list context, returns a two-element list of | |
538 | the position and the length of the matching part. | |
539 | .Sp | |
540 | \&\fBNotice\fR that the length of the matching part may differ from | |
541 | the length of \f(CW$substring\fR. | |
542 | .Sp | |
543 | \&\fBNote\fR that the position and the length are counted on the string | |
544 | after the process of preprocess, normalization, and rearrangement. | |
545 | Therefore, in case the specified string is not binary equal to | |
546 | the preprocessed/normalized/rearranged string, the position and the length | |
547 | may differ form those on the specified string. But it is guaranteed | |
548 | that, if matched, it returns a non-negative value as \f(CW$position\fR. | |
549 | .Sp | |
550 | If \f(CW$substring\fR does not match any part of \f(CW$string\fR, | |
551 | returns \f(CW\*(C`\-1\*(C'\fR in scalar context and | |
552 | an empty list in list context. | |
553 | .Sp | |
554 | e.g. you say | |
555 | .Sp | |
556 | .Vb 7 | |
557 | \& my $Collator = Unicode::Collate->new( normalization => undef, level => 1 ); | |
558 | \& my $str = "Ich mu\ex{00DF} studieren."; | |
559 | \& my $sub = "m\ex{00FC}ss"; | |
560 | \& my $match; | |
561 | \& if (my($pos,$len) = $Collator->index($str, $sub)) { | |
562 | \& $match = substr($str, $pos, $len); | |
563 | \& } | |
564 | .Ve | |
565 | .Sp | |
566 | Content-type: text/html