line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ###################################################################### Otakar Smrz, 2003/01/23 |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Encoding of Arabic: Tim Buckwalter's Notation ##################################### 2003/06/19 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Encode::Arabic::Buckwalter; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '14.1'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
12947
|
use 5.008; |
|
2
|
|
|
|
|
4
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
6
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
29
|
|
12
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
45
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
6
|
use Scalar::Util 'blessed'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
108
|
|
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
|
383
|
use Encode::Encoding; |
|
2
|
|
|
|
|
6751
|
|
|
2
|
|
|
|
|
39
|
|
17
|
2
|
|
|
2
|
|
15
|
use base 'Encode::Encoding'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
712
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
__PACKAGE__->Define('Buckwalter', 'Tim'); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $enmode; |
23
|
|
|
|
|
|
|
our $demode; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $optxml; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our %modemap = ( |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
'default' => 0, |
30
|
|
|
|
|
|
|
'undef' => 0, |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
'fullvocalize' => 0, |
33
|
|
|
|
|
|
|
'full' => 0, |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
'nowasla' => 4, |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
'vocalize' => 3, |
38
|
|
|
|
|
|
|
'nosukuun' => 3, |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
'novocalize' => 2, |
41
|
|
|
|
|
|
|
'novowels' => 2, |
42
|
|
|
|
|
|
|
'none' => 2, |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
'noshadda' => 1, |
45
|
|
|
|
|
|
|
'noneplus' => 1, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# use subs 'encoder', 'decoder'; # ignores later prototypes |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub encoder ($); # respect prototypes |
52
|
|
|
|
|
|
|
sub decoder ($); # respect prototypes |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub import { # perform import as if Encode were used one level before this module |
56
|
|
|
|
|
|
|
|
57
|
4
|
100
|
66
|
4
|
|
466
|
$optxml = defined $_[1] && $_[1] eq ':xml' ? 1 : 0; |
58
|
|
|
|
|
|
|
|
59
|
4
|
|
|
|
|
11
|
__PACKAGE__->enmode('full'); |
60
|
4
|
|
|
|
|
13
|
__PACKAGE__->demode('full'); |
61
|
|
|
|
|
|
|
|
62
|
4
|
|
|
|
|
8
|
splice @_, 1, 1; |
63
|
|
|
|
|
|
|
|
64
|
4
|
|
|
|
|
17
|
require Encode; |
65
|
|
|
|
|
|
|
|
66
|
4
|
100
|
|
|
|
37
|
push @Encode::ISA, 'Exporter' unless Encode->can('export_to_level'); |
67
|
|
|
|
|
|
|
|
68
|
4
|
|
|
|
|
320
|
Encode->export_to_level(1, @_); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub encode ($$;$) { |
73
|
2
|
|
|
2
|
1
|
1013
|
my (undef, $text, $check) = @_; |
74
|
|
|
|
|
|
|
|
75
|
2
|
50
|
|
|
|
6
|
$_[1] = '' if $check; # needed by in-place edit |
76
|
|
|
|
|
|
|
|
77
|
2
|
|
|
|
|
48
|
$text = encoder $text; |
78
|
|
|
|
|
|
|
|
79
|
2
|
50
|
|
|
|
16
|
$text = Encode::encode "utf8", $text if Encode::is_utf8($text); |
80
|
|
|
|
|
|
|
|
81
|
2
|
|
|
|
|
37
|
return $text; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub decode ($$;$) { |
86
|
4
|
|
|
4
|
1
|
429
|
my (undef, $text, $check) = @_; |
87
|
|
|
|
|
|
|
|
88
|
4
|
50
|
|
|
|
7
|
$_[1] = '' if $check; # needed by in-place edit |
89
|
|
|
|
|
|
|
|
90
|
4
|
50
|
|
|
|
15
|
$text = Encode::decode "utf8", $text unless Encode::is_utf8($text); |
91
|
|
|
|
|
|
|
|
92
|
4
|
|
|
|
|
150
|
$text = decoder $text; |
93
|
|
|
|
|
|
|
|
94
|
4
|
|
|
|
|
8
|
return $text; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub enmode ($$;$$) { |
99
|
4
|
|
|
4
|
1
|
6
|
my ($cls, $mode, $xml, $kshd) = @_; |
100
|
|
|
|
|
|
|
|
101
|
4
|
50
|
|
|
|
8
|
$cls = blessed $cls if ref $cls; |
102
|
4
|
50
|
|
|
|
8
|
$xml = $optxml unless defined $xml; |
103
|
|
|
|
|
|
|
|
104
|
4
|
50
|
|
|
|
8
|
$mode = 'undef' unless defined $mode; |
105
|
4
|
50
|
|
|
|
10
|
$mode = $modemap{$mode} if exists $modemap{$mode}; |
106
|
|
|
|
|
|
|
|
107
|
2
|
|
|
2
|
|
8
|
no strict 'refs'; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
391
|
|
108
|
|
|
|
|
|
|
|
109
|
4
|
|
|
|
|
4
|
my $return = ${ $cls . '::enmode' }; |
|
4
|
|
|
|
|
11
|
|
110
|
|
|
|
|
|
|
|
111
|
4
|
50
|
|
|
|
7
|
if (defined $mode) { |
112
|
|
|
|
|
|
|
|
113
|
4
|
|
|
|
|
5
|
${ $cls . '::enmode' } = $mode; |
|
4
|
|
|
|
|
7
|
|
114
|
|
|
|
|
|
|
|
115
|
4
|
50
|
|
|
|
39
|
my @set = ( |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
( $kshd |
118
|
|
|
|
|
|
|
? '' |
119
|
|
|
|
|
|
|
: q [\x{0640}] ) . |
120
|
|
|
|
|
|
|
q [\x{0623}\x{0624}\x{0625}] . |
121
|
|
|
|
|
|
|
q [\x{060C}\x{061B}\x{061F}] . |
122
|
|
|
|
|
|
|
q [\x{0621}\x{0622}\x{0626}-\x{063A}\x{0641}-\x{064A}] . |
123
|
|
|
|
|
|
|
q [\x{067E}\x{0686}\x{0698}\x{06A4}\x{06AF}] . |
124
|
|
|
|
|
|
|
q [\x{0660}-\x{0669}] . |
125
|
|
|
|
|
|
|
q [\x{0671}] . |
126
|
|
|
|
|
|
|
q [\x{0651}] . |
127
|
|
|
|
|
|
|
q [\x{064B}-\x{0650}\x{0670}] . |
128
|
|
|
|
|
|
|
q [\x{0652}] . |
129
|
|
|
|
|
|
|
( $kshd |
130
|
|
|
|
|
|
|
? q [\x{0640}] |
131
|
|
|
|
|
|
|
: '' ) |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
, |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
( $kshd |
136
|
|
|
|
|
|
|
? '' |
137
|
|
|
|
|
|
|
: q [_] ) . |
138
|
|
|
|
|
|
|
( $xml |
139
|
|
|
|
|
|
|
? q [OWI] |
140
|
|
|
|
|
|
|
: q [>&<] ) . |
141
|
|
|
|
|
|
|
q [,;?] . |
142
|
|
|
|
|
|
|
q ['|}AbptvjHxd*rzs$SDTZEgfqklmnhwYy] . |
143
|
|
|
|
|
|
|
q [PJRVG] . |
144
|
|
|
|
|
|
|
q [0-9] . |
145
|
|
|
|
|
|
|
( $mode == 0 |
146
|
|
|
|
|
|
|
? q [{] |
147
|
|
|
|
|
|
|
: q [A] ) . |
148
|
|
|
|
|
|
|
( $mode == 1 |
149
|
|
|
|
|
|
|
? '' |
150
|
|
|
|
|
|
|
: q [~] . ( $mode == 2 |
151
|
|
|
|
|
|
|
? '' |
152
|
|
|
|
|
|
|
: q [FNKaui`] . ( $mode == 3 |
153
|
|
|
|
|
|
|
? '' |
154
|
|
|
|
|
|
|
: q [o] ) ) ) |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
); |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
4
|
|
|
|
|
15
|
undef &encoder; |
160
|
|
|
|
|
|
|
|
161
|
2
|
|
|
2
|
0
|
918
|
eval q / |
|
2
|
|
|
0
|
|
54
|
|
|
2
|
|
|
|
|
23
|
|
|
4
|
|
|
|
|
964
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub encoder ($) { |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
$_[0] =~ tr[/ . $set[0] . q /] |
166
|
|
|
|
|
|
|
[/ . $set[1] . q /]d; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
return $_[0]; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
/; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
4
|
|
|
|
|
8920
|
return $return; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub demode ($$;$$) { |
178
|
4
|
|
|
4
|
1
|
7
|
my ($cls, $mode, $xml, $kshd) = @_; |
179
|
|
|
|
|
|
|
|
180
|
4
|
50
|
|
|
|
10
|
$cls = blessed $cls if ref $cls; |
181
|
4
|
50
|
|
|
|
9
|
$xml = $optxml unless defined $xml; |
182
|
|
|
|
|
|
|
|
183
|
4
|
50
|
|
|
|
6
|
$mode = 'undef' unless defined $mode; |
184
|
4
|
50
|
|
|
|
11
|
$mode = $modemap{$mode} if exists $modemap{$mode}; |
185
|
|
|
|
|
|
|
|
186
|
2
|
|
|
2
|
|
8
|
no strict 'refs'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
285
|
|
187
|
|
|
|
|
|
|
|
188
|
4
|
|
|
|
|
4
|
my $return = ${ $cls . '::demode' }; |
|
4
|
|
|
|
|
10
|
|
189
|
|
|
|
|
|
|
|
190
|
4
|
50
|
|
|
|
9
|
if (defined $mode) { |
191
|
|
|
|
|
|
|
|
192
|
4
|
|
|
|
|
5
|
${ $cls . '::demode' } = $mode; |
|
4
|
|
|
|
|
6
|
|
193
|
|
|
|
|
|
|
|
194
|
4
|
50
|
|
|
|
43
|
my @set = ( |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
( $kshd |
197
|
|
|
|
|
|
|
? '' |
198
|
|
|
|
|
|
|
: q [_] ) . |
199
|
|
|
|
|
|
|
( $xml |
200
|
|
|
|
|
|
|
? q [OWI] |
201
|
|
|
|
|
|
|
: q [>&<] ) . |
202
|
|
|
|
|
|
|
q [,;?] . |
203
|
|
|
|
|
|
|
q ['|}AbptvjHxd*rzs$SDTZEgfqklmnhwYy] . |
204
|
|
|
|
|
|
|
q [PJRVG] . |
205
|
|
|
|
|
|
|
q [0-9] . |
206
|
|
|
|
|
|
|
q [{] . |
207
|
|
|
|
|
|
|
q [~] . |
208
|
|
|
|
|
|
|
q [FNKaui`] . |
209
|
|
|
|
|
|
|
q [o] . |
210
|
|
|
|
|
|
|
( $kshd |
211
|
|
|
|
|
|
|
? q [_] |
212
|
|
|
|
|
|
|
: '' ) |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
, |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
( $kshd |
217
|
|
|
|
|
|
|
? '' |
218
|
|
|
|
|
|
|
: q [\x{0640}] ) . |
219
|
|
|
|
|
|
|
q [\x{0623}\x{0624}\x{0625}] . |
220
|
|
|
|
|
|
|
q [\x{060C}\x{061B}\x{061F}] . |
221
|
|
|
|
|
|
|
q [\x{0621}\x{0622}\x{0626}\x{0627}\x{0628}\x{0629}\x{062A}\x{062B}\x{062C}\x{062D}\x{062E}] . |
222
|
|
|
|
|
|
|
q [\x{062F}\x{0630}\x{0631}\x{0632}\x{0633}\x{0634}\x{0635}\x{0636}\x{0637}\x{0638}\x{0639}] . |
223
|
|
|
|
|
|
|
q [\x{063A}\x{0641}\x{0642}\x{0643}\x{0644}\x{0645}\x{0646}\x{0647}\x{0648}\x{0649}\x{064A}] . |
224
|
|
|
|
|
|
|
q [\x{067E}\x{0686}\x{0698}\x{06A4}\x{06AF}] . |
225
|
|
|
|
|
|
|
q [\x{0660}\x{0661}\x{0662}\x{0663}\x{0664}\x{0665}\x{0666}\x{0667}\x{0668}\x{0669}] . |
226
|
|
|
|
|
|
|
( $mode == 0 |
227
|
|
|
|
|
|
|
? q [\x{0671}] |
228
|
|
|
|
|
|
|
: q [\x{0627}] ) . |
229
|
|
|
|
|
|
|
( $mode == 1 |
230
|
|
|
|
|
|
|
? '' |
231
|
|
|
|
|
|
|
: q [\x{0651}] . ( $mode == 2 |
232
|
|
|
|
|
|
|
? '' |
233
|
|
|
|
|
|
|
: q [\x{064B}\x{064C}\x{064D}\x{064E}\x{064F}\x{0650}\x{0670}] . ( $mode == 3 |
234
|
|
|
|
|
|
|
? '' |
235
|
|
|
|
|
|
|
: q [\x{0652}] ) ) ) |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
); |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
|
240
|
4
|
|
|
|
|
10
|
undef &decoder; |
241
|
|
|
|
|
|
|
|
242
|
4
|
50
|
33
|
1
|
0
|
278
|
eval q / |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
2
|
|
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub decoder ($) { |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
$_[0] =~ tr[/ . $set[0] . q /] |
247
|
|
|
|
|
|
|
[/ . $set[1] . q /]/ . (($kshd or $mode > 0) ? 'd' : '') . q /; |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
return $_[0]; |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
/; |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
|
254
|
4
|
|
|
|
|
2488
|
return $return; |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
1; |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
__END__ |