line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::CLDR::Collator; |
2
|
|
|
|
|
|
|
|
3
|
20
|
|
|
20
|
|
101
|
use version; |
|
20
|
|
|
|
|
34
|
|
|
20
|
|
|
|
|
144
|
|
4
|
|
|
|
|
|
|
our $VERSION = version->declare('v0.27.2'); |
5
|
|
|
|
|
|
|
|
6
|
20
|
|
|
20
|
|
2258
|
use v5.10; |
|
20
|
|
|
|
|
59
|
|
|
20
|
|
|
|
|
769
|
|
7
|
20
|
|
|
20
|
|
105
|
use mro 'c3'; |
|
20
|
|
|
|
|
28
|
|
|
20
|
|
|
|
|
170
|
|
8
|
20
|
|
|
20
|
|
678
|
use utf8; |
|
20
|
|
|
|
|
32
|
|
|
20
|
|
|
|
|
137
|
|
9
|
20
|
|
|
20
|
|
736
|
use if $^V ge v5.12.0, feature => 'unicode_strings'; |
|
20
|
|
|
|
|
40
|
|
|
20
|
|
|
|
|
351
|
|
10
|
|
|
|
|
|
|
|
11
|
20
|
|
|
20
|
|
2614
|
use Unicode::Normalize('NFD'); |
|
20
|
|
|
|
|
33
|
|
|
20
|
|
|
|
|
1622
|
|
12
|
|
|
|
|
|
|
|
13
|
20
|
|
|
20
|
|
99
|
use Moose; |
|
20
|
|
|
|
|
27
|
|
|
20
|
|
|
|
|
176
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with 'Locale::CLDR::CollatorBase'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'type' => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => 'Str', |
20
|
|
|
|
|
|
|
default => 'standard', |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'locale' => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
isa => 'Locale::CLDR', |
26
|
|
|
|
|
|
|
required => 1, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has 'strength' => ( |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
isa => 'Int', |
32
|
|
|
|
|
|
|
default => 3, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Set up the locale overrides |
36
|
|
|
|
|
|
|
sub BUILD { |
37
|
5
|
|
|
5
|
0
|
6763
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
254
|
my $overrides = $self->locale->_collation_overrides($self->type); |
40
|
|
|
|
|
|
|
|
41
|
5
|
|
|
|
|
40
|
foreach my $override (@$overrides) { |
42
|
0
|
|
|
|
|
0
|
$self->_set_ce(@$override); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _get_sort_digraphs_rx { |
47
|
52
|
|
|
52
|
|
71
|
my $self = shift; |
48
|
|
|
|
|
|
|
|
49
|
52
|
|
|
|
|
2338
|
my $digraphs = $self->_digraphs(); |
50
|
|
|
|
|
|
|
|
51
|
52
|
|
|
|
|
265
|
my $rx = join '|', @$digraphs, '.'; |
52
|
|
|
|
|
|
|
|
53
|
52
|
|
|
|
|
320
|
return qr/$rx/; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Converts $string into a string of Collation Elements |
57
|
|
|
|
|
|
|
sub getSortKey { |
58
|
52
|
|
|
52
|
0
|
102
|
my ($self, $string) = @_; |
59
|
|
|
|
|
|
|
|
60
|
52
|
|
|
|
|
342
|
$string = NFD($string); |
61
|
|
|
|
|
|
|
|
62
|
52
|
|
|
|
|
137
|
my $entity_rx = $self->_get_sort_digraphs_rx(); |
63
|
|
|
|
|
|
|
|
64
|
52
|
|
|
|
|
406
|
(my $ce = $string) =~ s/($entity_rx)/ $self->get_collation_element($1) /eg; |
|
142
|
|
|
|
|
447
|
|
65
|
|
|
|
|
|
|
|
66
|
52
|
|
|
|
|
391
|
return $ce; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub generate_ce { |
70
|
0
|
|
|
0
|
0
|
0
|
my ($self, $character) = @_; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
0
|
my $base; |
73
|
|
|
|
|
|
|
|
74
|
20
|
0
|
|
20
|
|
123362
|
if ($character =~ /\p{Unified_Ideograph}/) { |
|
20
|
|
|
|
|
44
|
|
|
20
|
|
|
|
|
270
|
|
|
0
|
|
|
|
|
0
|
|
75
|
0
|
0
|
0
|
|
|
0
|
if ($character =~ /\p{Block=CJK_Unified_Ideograph}/ || $character =~ /\p{Block=CJK_Compatibility_Ideographs}/) { |
76
|
0
|
|
|
|
|
0
|
$base = 0xFB40; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
else { |
79
|
0
|
|
|
|
|
0
|
$base = 0xFB80; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
else { |
83
|
0
|
|
|
|
|
0
|
$base = 0xFBC0; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
0
|
my $aaaa = $base + unpack( 'L', (pack ('L', ord($character)) >> 15)); |
87
|
0
|
|
|
|
|
0
|
my $bbbb = unpack('L', (pack('L', ord($character)) & 0x7FFF) | 0x8000); |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
0
|
return join '', map {chr($_)} $aaaa, 0x0020, 0x0002,0, $bbbb,0,0,0; |
|
0
|
|
|
|
|
0
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# sorts a list according to the locales collation rules |
93
|
|
|
|
|
|
|
sub sort { |
94
|
9
|
|
|
9
|
0
|
112489
|
my $self = shift; |
95
|
|
|
|
|
|
|
|
96
|
52
|
|
|
|
|
229
|
return map { $_->[0]} |
|
90
|
|
|
|
|
167
|
|
97
|
52
|
|
|
|
|
184
|
sort { $a->[1] cmp $b->[1] } |
98
|
9
|
|
|
|
|
42
|
map { [$_, $self->getSortKey($_)] } |
99
|
|
|
|
|
|
|
@_; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub cmp { |
103
|
0
|
|
|
0
|
0
|
|
my ($self, $a, $b) = @_; |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
return $self->getSortKey($a) cmp $self->getSortKey($b); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub eq { |
109
|
0
|
|
|
0
|
0
|
|
my ($self, $a, $b) = @_; |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
return $self->getSortKey($a) eq $self->getSortKey($b); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub ne { |
115
|
0
|
|
|
0
|
0
|
|
my ($self, $a, $b) = @_; |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
return $self->getSortKey($a) ne $self->getSortKey($b); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub lt { |
121
|
0
|
|
|
0
|
0
|
|
my ($self, $a, $b) = @_; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
return $self->getSortKey($a) lt $self->getSortKey($b); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub le { |
127
|
0
|
|
|
0
|
0
|
|
my ($self, $a, $b) = @_; |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
return $self->getSortKey($a) le $self->getSortKey($b); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
sub gt { |
132
|
0
|
|
|
0
|
0
|
|
my ($self, $a, $b) = @_; |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
return $self->getSortKey($a) lt $self->getSortKey($b); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub ge { |
138
|
0
|
|
|
0
|
0
|
|
my ($self, $a, $b) = @_; |
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
return $self->getSortKey($a) le $self->getSortKey($b); |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# Get Human readable sort key |
144
|
|
|
|
|
|
|
sub viewSortKey { |
145
|
0
|
|
|
0
|
0
|
|
my ($self, $sort_key) = @_; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# my $sort_key = $self->getSortKey($a); |
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
my @levels = split/\x0/, $sort_key; |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
foreach my $level (@levels) { |
152
|
0
|
|
|
|
|
|
$level = join ' ', map { sprintf '%0.4X', ord } split //, $level; |
|
0
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
return '[ ' . join (' | ', @levels) . ' ]'; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
20
|
|
|
20
|
|
363198
|
no Moose; |
|
20
|
|
|
|
|
46
|
|
|
20
|
|
|
|
|
195
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
1; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# vim: tabstop=4 |