File Coverage

blib/lib/Encode/Arabic/ArabTeX.pm
Criterion Covered Total %
statement 63 342 18.4
branch 4 216 1.8
condition 4 30 13.3
subroutine 19 29 65.5
pod 6 10 60.0
total 96 627 15.3


line stmt bran cond sub pod time code
1             # ##################################################################### Otakar Smrz, 2003/01/23
2             #
3             # Encoding of Arabic: ArabTeX Notation by Klaus Lagally ############################ 2003/06/19
4              
5             # $Id: ArabTeX.pm 717 2008-10-02 22:28:12Z smrz $
6              
7             package Encode::Arabic::ArabTeX;
8              
9 5     5   23577 use 5.008;
  5         17  
  5         190  
10              
11 5     5   25 use strict;
  5         18  
  5         140  
12 5     5   26 use warnings;
  5         9  
  5         144  
13              
14 5     5   28 use Scalar::Util 'blessed';
  5         7  
  5         608  
15 5     5   30 use Carp;
  5         13  
  5         558  
16              
17             our $VERSION = do { q $Revision: 717 $ =~ /(\d+)/; sprintf "%4.2f", $1 / 100 };
18              
19              
20 5     5   5422 use Encode::Encoding;
  5         87147  
  5         218  
21 5     5   49 use base 'Encode::Encoding';
  5         7  
  5         647  
22              
23             __PACKAGE__->Define('ArabTeX', 'Lagally', 'TeX');
24              
25              
26 5     5   2808 use Encode::Mapper ':others', ':silent', ':join';
  5         14  
  5         44  
27              
28              
29             our %options; # records of options per package .. global register
30             our %option; # options of the caller package .. used with local
31              
32             our $enmode;
33             our $demode;
34              
35             our $enlevel = 2;
36             our $delevel = 3;
37              
38             our %modemap = (
39              
40             'default' => 3,
41             'undef' => 0,
42              
43             'fullvocalize' => 4,
44             'full' => 4,
45              
46             'vocalize' => 3,
47             'nosukuun' => 3,
48              
49             'novocalize' => 2,
50             'novowels' => 2,
51             'none' => 2,
52              
53             'noshadda' => 1,
54             'noneplus' => 1,
55             );
56              
57              
58             sub import { # perform import as if Encode were used one level before this module
59              
60 4 100 66 4   2466 if (defined $_[1] and $_[1] eq ':xml') { # interfere little with possible Encode's options
61              
62 254         245 Encode::Mapper->options (
63              
64             'override' => [ # override rules of these LHS .. no other tricks ^^
65              
66             ( # combinations of '<' and '>' with the other bytes
67             map {
68              
69 1         5 my $x = chr $_;
70              
71 254         948 "<" . $x, [ "<" . $x, ">" ], # propagate the '>' sign implying ..
72             ">" . $x, [ $x, ">" ], # .. preservation of the bytes
73              
74             } 0x00 .. 0x3B, 0x3D, 0x3F .. 0xFF
75             ),
76              
77             ">>", ">", # stop the whole process ..
78             "<>", "<>", # .. do not even start it
79              
80             "><", [ "<", ">" ], # rather than nested '<' and '>', ..
81             "<<", [ "<<", ">" ],
82              
83             ">\\<", [ "<", ">" ], # .. prefer these escape sequences
84             ">\\\\", [ "\\", ">" ],
85             ">\\>", [ ">", ">" ],
86              
87             ">", ">", # singular symbols may migrate right ..
88             "<", "<", # .. or preserve the rest of the data
89             ]
90              
91             );
92              
93 1         49 splice @_, 1, 1;
94             }
95              
96 4 50 33     18 if (defined $_[1] and $_[1] eq ':simple') {
97              
98 0         0 __PACKAGE__->options($_[1]);
99 0         0 splice @_, 1, 1;
100             }
101              
102 4 50 33     17 if (defined $_[1] and $_[1] eq ':describe') {
103              
104 0         0 __PACKAGE__->options($_[1]);
105 0         0 splice @_, 1, 1;
106             }
107              
108 4         174 require Encode;
109              
110 4         188 Encode->export_to_level(1, @_); # here comes the only trick ^^
111             }
112              
113              
114             sub options ($%) {
115 0     0 0   my $cls = shift @_;
116 0           my ($i, $opt, %opt);
117              
118 0           my @returns = %option;
119              
120 0           while (@_) {
121              
122 0           $opt = lc shift @_;
123              
124 0 0         if ($opt =~ /^\:/) {
125              
126 0 0 0       $opt eq ':simple' and $opt{'non-quoting'} = 1 and $opt{'non-refined'} = 1 and next;
      0        
127 0 0 0       $opt eq ':describe' and $opt{'describe'} = 1 and next;
128             }
129             else {
130              
131 0           $opt =~ /^\-*(.*)$/;
132 0           $opt{$1} = shift @_;
133             }
134             }
135              
136 0 0         return %opt unless defined $cls;
137              
138 0           $option{$_} = $opt{$_} foreach keys %opt;
139              
140 0           return @returns;
141             }
142              
143              
144             sub encode ($$;$) {
145 0     0 1   my ($cls, $text, $check) = @_;
146              
147 0 0         $cls = blessed $cls if ref $cls;
148              
149 5     5   44 no strict 'refs';
  5         11  
  5         742  
150              
151 0 0         $cls->encoder() unless defined ${ $cls . '::encoder' };
  0            
152              
153 0           return Encode::Mapper->encode($text, ${ $cls . '::encoder' }, undef);
  0            
154             }
155              
156              
157             sub decode ($$;$) {
158 0     0 1   my ($cls, $text, $check) = @_;
159              
160 0 0         $cls = blessed $cls if ref $cls;
161              
162 5     5   25 no strict 'refs';
  5         11  
  5         5718  
163              
164 0 0         $cls->decoder() unless defined ${ $cls . '::decoder' };
  0            
165              
166 0           return Encode::Mapper->decode($text, ${ $cls . '::decoder' }, 'utf8');
  0            
167             }
168              
169              
170             sub encoder ($@) {
171 0     0 1   my $cls = shift @_;
172              
173 0           my $encoder = $cls->eecoder('encoder', @_);
174              
175 0 0 0       return $encoder unless defined $encoder and $encoder == -1;
176              
177 0           $encoder = [];
178              
179              
180 0           $encoder->[0] = Encode::Mapper->compile (
181              
182             [
183             'silent' => 0,
184             ],
185              
186             (
187             map {
188              
189 0           chr 0x0660 + $_, "" . $_,
190              
191             } 0 .. 9
192             ),
193              
194             "\x{064B}", "aN", # 240 "\xF0", # "\xD9\x8B"
195             "\x{064C}", "uN", # 241 "\xF1", # "\xD9\x8C"
196             "\x{064D}", "iN", # 242 "\xF2", # "\xD9\x8D"
197             "\x{064E}", "a", # 243 "\xF3", # "\xD9\x8E"
198             "\x{064F}", "u", # 245 "\xF5", # "\xD9\x8F"
199             "\x{0650}", "i", # 246 "\xF6", # "\xD9\x90"
200             "\x{0670}", "_a",
201             "\x{0657}", "_u",
202             "\x{0656}", "_i",
203              
204             "\x{060C}", ",", # 161 "\xA1", # "\xD8\x8C" right-to-left-comma
205             "\x{061B}", ";", # 186 "\xBA", # "\xD8\x9B" right-to-left-semicolon
206             "\x{061F}", "?", # 191 "\xBF", # "\xD8\x9F" right-to-left-question-mark
207             "\x{0621}", "'", # 193 "\xC1", # "\xD8\xA1" hamza-on-the-line
208             "\x{0622}", "'A", # 194 "\xC2", # "\xD8\xA2" madda-over-'alif
209             "\x{0623}", "'", # 195 "\xC3", # "\xD8\xA3" hamza-over-'alif
210             "\x{0624}", "'", # 196 "\xC4", # "\xD8\xA4" hamza-over-waaw
211             "\x{0625}", "'", # 197 "\xC5", # "\xD8\xA5" hamza-under-'alif
212             "\x{0626}", "'", # 198 "\xC6", # "\xD8\xA6" hamza-over-yaa'
213             "\x{0627}", "A", # 199 "\xC7", # "\xD8\xA7" bare 'alif
214             "\x{0628}", "b", # 200 "\xC8", # "\xD8\xA8"
215             "\x{0629}", "T", # 201 "\xC9", # "\xD8\xA9"
216             "\x{062A}", "t", # 202 "\xCA", # "\xD8\xAA"
217             "\x{062B}", "_t", # 203 "\xCB", # "\xD8\xAB" <_t>
218             "\x{062C}", "^g", # 204 "\xCC", # "\xD8\xAC" <^g>
219             "\x{062D}", ".h", # 205 "\xCD", # "\xD8\xAD" <.h>
220             "\x{062E}", "_h", # 206 "\xCE", # "\xD8\xAE" <_h>
221             "\x{062F}", "d", # 207 "\xCF", # "\xD8\xAF"
222             "\x{0630}", "_d", # 208 "\xD0", # "\xD8\xB0" <_d>
223             "\x{0631}", "r", # 209 "\xD1", # "\xD8\xB1"
224             "\x{0632}", "z", # 210 "\xD2", # "\xD8\xB2"
225             "\x{0633}", "s", # 211 "\xD3", # "\xD8\xB3"
226             "\x{0634}", "^s", # 212 "\xD4", # "\xD8\xB4" <^s>
227             "\x{0635}", ".s", # 213 "\xD5", # "\xD8\xB5" <.s>
228             "\x{0636}", ".d", # 214 "\xD6", # "\xD8\xB6" <.d>
229             "\x{0637}", ".t", # 216 "\xD8", # "\xD8\xB7" <.t>
230             "\x{0638}", ".z", # 217 "\xD9", # "\xD8\xB8" <.z>
231             "\x{0639}", "`", # 218 "\xDA", # "\xD8\xB9" <`>
232             "\x{063A}", ".g", # 219 "\xDB", # "\xD8\xBA" <.g>
233             "\x{0640}", "--", # 220 "\xDC", # "\xD9\x80" ta.twiil
234             "\x{0641}", "f", # 221 "\xDD", # "\xD9\x81"
235             "\x{0642}", "q", # 222 "\xDE", # "\xD9\x82"
236             "\x{0643}", "k", # 223 "\xDF", # "\xD9\x83"
237             "\x{0644}", "l", # 225 "\xE1", # "\xD9\x84"
238             "\x{0645}", "m", # 227 "\xE3", # "\xD9\x85"
239             "\x{0646}", "n", # 228 "\xE4", # "\xD9\x86"
240             "\x{0647}", "h", # 229 "\xE5", # "\xD9\x87"
241             "\x{0648}", "w", # 230 "\xE6", # "\xD9\x88"
242             "\x{0649}", "Y", # 236 "\xEC", # "\xD9\x89" 'alif maq.suura
243             "\x{064A}", "y", # 237 "\xED", # "\xD9\x8A"
244             "\x{0651}", "\\shadda{}", # 248 "\xF8", # "\xD9\x91" ^sadda
245             # "\x{0652}", '"', # 250 "\xFA", # "\xD9\x92" sukuun
246             "\x{0652}", "", # 250 "\xFA", # "\xD9\x92" sukuun
247             "\x{0671}", "A", # 199 "\xC7", # "\xD9\xB1" wa.sla-on-'alif
248              
249             "\x{067E}", "p",
250             "\x{06A4}", "v",
251             "\x{06AF}", "g",
252              
253             "\x{0681}", "c",
254             "\x{0686}", "^c",
255             "\x{0685}", ",c",
256             "\x{0698}", "^z",
257             "\x{06AD}", "^n",
258             "\x{06B5}", "^l",
259             "\x{0695}", ".r",
260              
261             "\x{0628}\x{0651}", "bb", # 200 "\xC8", # "\xD8\xA8"
262             "\x{062A}\x{0651}", "tt", # 202 "\xCA", # "\xD8\xAA"
263             "\x{062B}\x{0651}", "_t_t", # 203 "\xCB", # "\xD8\xAB" <_t>
264             "\x{062C}\x{0651}", "^g^g", # 204 "\xCC", # "\xD8\xAC" <^g>
265             "\x{062D}\x{0651}", ".h.h", # 205 "\xCD", # "\xD8\xAD" <.h>
266             "\x{062E}\x{0651}", "_h_h", # 206 "\xCE", # "\xD8\xAE" <_h>
267             "\x{062F}\x{0651}", "dd", # 207 "\xCF", # "\xD8\xAF"
268             "\x{0630}\x{0651}", "_d_d", # 208 "\xD0", # "\xD8\xB0" <_d>
269             "\x{0631}\x{0651}", "rr", # 209 "\xD1", # "\xD8\xB1"
270             "\x{0632}\x{0651}", "zz", # 210 "\xD2", # "\xD8\xB2"
271             "\x{0633}\x{0651}", "ss", # 211 "\xD3", # "\xD8\xB3"
272             "\x{0634}\x{0651}", "^s^s", # 212 "\xD4", # "\xD8\xB4" <^s>
273             "\x{0635}\x{0651}", ".s.s", # 213 "\xD5", # "\xD8\xB5" <.s>
274             "\x{0636}\x{0651}", ".d.d", # 214 "\xD6", # "\xD8\xB6" <.d>
275             "\x{0637}\x{0651}", ".t.t", # 216 "\xD8", # "\xD8\xB7" <.t>
276             "\x{0638}\x{0651}", ".z.z", # 217 "\xD9", # "\xD8\xB8" <.z>
277             "\x{0639}\x{0651}", "``", # 218 "\xDA", # "\xD8\xB9" <`>
278             "\x{063A}\x{0651}", ".g.g", # 219 "\xDB", # "\xD8\xBA" <.g>
279             "\x{0641}\x{0651}", "ff", # 221 "\xDD", # "\xD9\x81"
280             "\x{0642}\x{0651}", "qq", # 222 "\xDE", # "\xD9\x82"
281             "\x{0643}\x{0651}", "kk", # 223 "\xDF", # "\xD9\x83"
282             "\x{0644}\x{0651}", "ll", # 225 "\xE1", # "\xD9\x84"
283             "\x{0645}\x{0651}", "mm", # 227 "\xE3", # "\xD9\x85"
284             "\x{0646}\x{0651}", "nn", # 228 "\xE4", # "\xD9\x86"
285             "\x{0647}\x{0651}", "hh", # 229 "\xE5", # "\xD9\x87"
286             "\x{0648}\x{0651}", "ww", # 230 "\xE6", # "\xD9\x88"
287             "\x{064A}\x{0651}", "yy", # 237 "\xED", # "\xD9\x8A"
288              
289             );
290              
291              
292 5     5   37 no strict 'refs';
  5         9  
  5         110106  
293              
294 0           ${ $cls . '::encoder' } = $encoder;
  0            
295              
296 0 0         if ($option{'describe'}) {
297              
298 0           $_->describe('') foreach @{${ $cls . '::encoder' }};
  0            
  0            
299             }
300              
301 0 0         $cls->enmode(defined ${ $cls . '::enmode' } ? ${ $cls . '::enmode' } : 'default');
  0            
  0            
302              
303 0           return ${ $cls . '::encoder' };
  0            
304             }
305              
306              
307             sub decoder ($@) {
308 0     0 1   my $cls = shift @_;
309              
310 0           my $decoder = $cls->eecoder('decoder', @_);
311              
312 0 0 0       return $decoder unless defined $decoder and $decoder == -1;
313              
314 0           $decoder = [];
315              
316              
317 0           my @sunny = (
318             [ "t", "\x{062A}" ], # "\xD8\xAA"
319             [ "_t", "\x{062B}" ], # "\xD8\xAB" <_t>
320             [ "d", "\x{062F}" ], # "\xD8\xAF"
321             [ "_d", "\x{0630}" ], # "\xD8\xB0" <_d>
322             [ "r", "\x{0631}" ], # "\xD8\xB1"
323             [ "z", "\x{0632}" ], # "\xD8\xB2"
324             [ "s", "\x{0633}" ], # "\xD8\xB3"
325             [ "^s", "\x{0634}" ], # "\xD8\xB4" <^s>
326             [ ".s", "\x{0635}" ], # "\xD8\xB5" <.s>
327             [ ".d", "\x{0636}" ], # "\xD8\xB6" <.d>
328             [ ".t", "\x{0637}" ], # "\xD8\xB7" <.t>
329             [ ".z", "\x{0638}" ], # "\xD8\xB8" <.z>
330             [ "l", "\x{0644}" ], # "\xD9\x84"
331             [ "n", "\x{0646}" ], # "\xD9\x86"
332             );
333              
334              
335 0           my @empty = (
336             [ "|", "" ], # ArabTeX's "invisible consonant"
337             [ "", "\x{0627}" ], # "\xD8\xA7" bare 'alif
338             );
339              
340              
341 0           my @taaaa = (
342             [ "T", "\x{0629}" ], # "\xD8\xA9"
343             [ "H", "\x{0629}" ], # "\xD8\xA9"
344             );
345              
346              
347 0           my @moony = (
348             [ "'A", "\x{0622}" ], # "\xD8\xA2" madda-over-'alif
349             [ "'a", "\x{0623}" ], # "\xD8\xA3" hamza-over-'alif
350             [ "'i", "\x{0625}" ], # "\xD8\xA5" hamza-under-'alif
351             [ "'w", "\x{0624}" ], # "\xD8\xA4" hamza-over-waaw
352             [ "'y", "\x{0626}" ], # "\xD8\xA6" hamza-over-yaa'
353             [ "'|", "\x{0621}" ], # "\xD8\xA1" hamza-on-the-line
354             [ "b", "\x{0628}" ], # "\xD8\xA8"
355             [ "^g", "\x{062C}" ], # "\xD8\xAC" <^g>
356             [ ".h", "\x{062D}" ], # "\xD8\xAD" <.h>
357             [ "_h", "\x{062E}" ], # "\xD8\xAE" <_h>
358             [ "`", "\x{0639}" ], # "\xD8\xB9" <`>
359             [ ".g", "\x{063A}" ], # "\xD8\xBA" <.g>
360             [ "f", "\x{0641}" ], # "\xD9\x81"
361             [ "q", "\x{0642}" ], # "\xD9\x82"
362             [ "k", "\x{0643}" ], # "\xD9\x83"
363             [ "m", "\x{0645}" ], # "\xD9\x85"
364             [ "h", "\x{0647}" ], # "\xD9\x87"
365             [ "w", "\x{0648}" ], # "\xD9\x88"
366             [ "y", "\x{064A}" ], # "\xD9\x8A"
367              
368             [ "B", "\x{0640}" ], # ArabTeX's "consonantal ta.twiil"
369              
370             [ "p", "\x{067E}" ],
371             [ "v", "\x{06A4}" ],
372             [ "g", "\x{06AF}" ],
373              
374             [ "c", "\x{0681}" ], # .ha with hamza
375             [ "^c", "\x{0686}" ], # gim with three
376             [ ",c", "\x{0685}" ], # _ha with three
377             [ "^z", "\x{0698}" ], # zay with three
378             [ "^n", "\x{06AD}" ], # kaf with three
379             [ "^l", "\x{06B5}" ], # lam with a bow above
380             [ ".r", "\x{0695}" ], # ra' with a bow below
381             );
382              
383              
384 0           my @scope = (
385             "b", "t", "_t", "^g", ".h", "_h", "d", "_d", "r", "z", "s", "^s", ".s",
386             ".d", ".t", ".z", "`", ".g", "f", "q", "k", "l", "m", "n", "h", "w",
387             "p", "v", "g", "c", "^c", ",c", "^z", "^n", "^l", ".r", "|", "B",
388             # "'", "y" treated specifically in some cases -- "T", "H" must as well
389             );
390              
391              
392 0 0         $decoder->[0] = Encode::Mapper->compile (
393              
394             [
395             'silent' => 0,
396             ],
397              
398             "_A", [ "", "Y" ],
399             "_U", [ "", "U" ],
400              
401             "WA", [ "", "W" ],
402              
403             "y_A", [ "", "yY" ],
404              
405             "yaN_A", [ "", "yaNY" ],
406             "yaNY", [ "", "yaN" ],
407              
408             "yY", [ "y", "A" ],
409              
410             # word-internal occurrence
411              
412             "TA", [ "t", "A" ],
413             "TU", [ "t", "U" ],
414             "TI", [ "t", "I" ],
415             "TY", [ "t", "Y" ],
416              
417             "T_I", [ "t", "_I" ],
418              
419             "T_A", [ "t", "_A" ],
420             "T_U", [ "t", "_U" ],
421              
422             (
423             map {
424              
425 0           "T" . $_, [ "t", $_ ],
426              
427             "Ta" . $_, [ "t", "a" . $_ ],
428             "Tu" . $_, [ "t", "u" . $_ ],
429             "Ti" . $_, [ "t", "i" . $_ ],
430              
431             ( $option{'non-quoting'} ? () : (
432              
433             "T\"" . $_, [ "t", "\"" . $_ ],
434              
435             "T\"a" . $_, [ "t", "\"a" . $_ ],
436             "T\"u" . $_, [ "t", "\"u" . $_ ],
437             "T\"i" . $_, [ "t", "\"i" . $_ ],
438              
439             ) ),
440              
441             } @scope, "y" # "T", "H", "W"
442             ),
443              
444             "Ta'", [ "t", "a'" ],
445             "Tu'", [ "t", "u'" ],
446             "Ti'", [ "t", "i'" ],
447              
448             ( $option{'non-quoting'} ? () : (
449              
450             "T\"'", [ "t", "\"'" ],
451              
452             "T\"a'", [ "t", "\"a'" ],
453             "T\"u'", [ "t", "\"u'" ],
454             "T\"i'", [ "t", "\"i'" ],
455              
456             ) ),
457              
458             (
459             map {
460              
461 0           "Y" . $_, [ "A", $_ ],
462              
463             } @scope, "y", "T", "H" # "W"
464             ),
465              
466             # vowel-quoted sequences
467              
468             ( $option{'non-quoting'} ? (
469              
470             "\"", "", # use non-quoting quotes only on no purpose ^^
471              
472             ) : (
473              
474             "\"", "\"",
475              
476             ) ),
477              
478             # general non-protection of \TeX directives
479             (
480             map {
481              
482 0           "\\cap" . $_, [ "\\", "cap" . $_ ],
483              
484             } 'A' .. 'Z', 'a' .. 'z', '_', '0' .. '9'
485             ),
486              
487             "\\", "\\",
488              
489             # strict \cap removal and white-space collapsing
490             (
491             map {
492              
493 0           "\\cap" . $_ . "\x09", [ "", "\\cap " ],
494             "\\cap" . $_ . "\x0A", [ "", "\\cap " ],
495             "\\cap" . $_ . "\x0D", [ "", "\\cap " ],
496             "\\cap" . $_ . "\x20", [ "", "\\cap " ],
497              
498             "\\cap" . $_, "",
499              
500             } "\x09", "\x0A", "\x0D", "\x20"
501             ),
502              
503             "\\cap", "",
504              
505             # interfering rarely with the notation, or erroneous
506              
507             "^A'a", [ "^A'|", "a" ],
508              
509             "^A", [ "^A", "|" ],
510             "^I", [ "^I", "|" ],
511             "^U", [ "^U", "|" ],
512              
513             "_a", [ "_a", "|" ],
514             "_i", [ "_i", "|" ],
515             "_u", [ "_u", "|" ],
516              
517             "_aA", [ "_aA", "|" ],
518             "_aY", [ "_aY", "|" ],
519             "_aU", [ "_aU", "|" ],
520             "_aI", [ "_aI", "|" ],
521              
522             "'_a", [ "", "_a" ],
523             "'_i", [ "", "_i" ],
524             "'_u", [ "", "_u" ],
525              
526             "'^A", [ "", "^A" ],
527             "'^I", [ "", "^I" ],
528             "'^U", [ "", "^U" ],
529              
530             # word-initial carriers
531              
532             "'", "'a", # covers much implicitly
533              
534             "'i", [ "'i", "i" ],
535              
536             "'A", [ "'", "A" ],
537             "'I", [ "'i", "I" ],
538              
539             "'_I", [ "'i", "_I" ],
540              
541             "''", "'a'a", # .. still needed ^^
542              
543             "''i", [ "'i'i", "i" ],
544             "''I", [ "'i'i", "I" ],
545              
546             "''_I", [ "'i'i", "_I" ],
547              
548             ( $option{'non-quoting'} ? () : (
549              
550             "'\"i", [ "'i\"", "i" ],
551              
552             "'\"A", [ "'", "A" ],
553             "'\"I", [ "'i\"", "I" ],
554              
555             "'\"_I", [ "'i\"", "_I" ],
556              
557             "''\"i", [ "'i'i\"", "i" ],
558             "''\"I", [ "'i'i\"", "I" ],
559              
560             "''\"_I", [ "'i'i\"", "_I" ],
561              
562             ) ),
563              
564             # word-final carriers
565              
566             "Y'", "A'|",
567              
568             "A'", "A'|",
569             "I'", "I'|",
570             "U'", "U'|",
571              
572             # "a'", "a'a",
573             # "a'i", "a'ii",
574             # "a'\"i", "a'i\"i",
575              
576             "i'", "i'y",
577             "u'", "u'w",
578              
579             "Y''", "A'|'|",
580              
581             "A''", "A'|'|",
582             "I''", "I'|'|",
583             "U''", "U'|'|",
584              
585             # "a''", "a'a'a",
586             # "a''i", "a'i'ii",
587             # "a''\"i", "a'i'i\"i",
588              
589             "i''", "i'y'y",
590             "u''", "u'w'w",
591              
592             (
593             map { # covers cases in the map below over @scope and # quoted included
594              
595 0 0         $_ . "'", $_ . "'|",
596             $_ . "''", $_ . "'|'|",
597              
598             } @scope, "y", $option{'non-quoting'} ? () : "\"" # quoted included
599             ),
600              
601             "T'", "t'|",
602             "T''", "t'|'|",
603              
604             # word-internal carriers # doubled
605              
606             "a'A", [ "a'", "A" ], # unclear ^^
607             "a'I", [ "a'y", "I" ], "a''I", [ "a'y'y", "I" ],
608             "a'U", [ "a'w", "U" ], "a''U", [ "a'w'w", "U" ],
609              
610             "a'_I", [ "a'y", "_I" ], "a''_I", [ "a'y'y", "_I" ],
611              
612             "u'I", [ "u'y", "I" ], "u''I", [ "u'y'y", "I" ],
613              
614             "u'_I", [ "u'y", "_I" ], "u''_I", [ "u'y'y", "_I" ],
615              
616             "I'aN", [ "I'y", "aN" ], "I''aN", [ "I'y'y", "aN" ],
617             "y'aN", [ "y'y", "aN" ], "y''aN", [ "y'y'y", "aN" ],
618              
619             "A'A", [ "A'|", "A" ], "A''A", [ "A'|'|", "A" ],
620             "A'I", [ "A'y", "I" ], "A''I", [ "A'y'y", "I" ],
621             "A'U", [ "A'w", "U" ], "A''U", [ "A'w'w", "U" ],
622             "A'Y", [ "A'|", "Y" ], "A''Y", [ "A'|'|", "Y" ],
623              
624             "A'_I", [ "A'y", "_I" ], "A''_I", [ "A'y'y", "_I" ],
625              
626             "A'_U", [ "", "A'U" ], "A''_U", [ "", "A''U" ],
627             "A'_A", [ "", "A'Y" ], "A''_A", [ "", "A''Y" ],
628              
629             "I'A", [ "I'y", "A" ], "I''A", [ "I'y'y", "A" ],
630             "I'I", [ "I'y", "I" ], "I''I", [ "I'y'y", "I" ],
631             "I'U", [ "I'y", "U" ], "I''U", [ "I'y'y", "U" ],
632             "I'Y", [ "I'y", "Y" ], "I''Y", [ "I'y'y", "Y" ],
633              
634             "I'_I", [ "I'y", "_I" ], "I''_I", [ "I'y'y", "_I" ],
635              
636             "I'_U", [ "", "I'U" ], "I''_U", [ "", "I''U" ],
637             "I'_A", [ "", "I'Y" ], "I''_A", [ "", "I''Y" ],
638              
639             "y'A", [ "y'y", "A" ], "y''A", [ "y'y'y", "A" ],
640             "y'I", [ "y'y", "I" ], "y''I", [ "y'y'y", "I" ],
641             "y'U", [ "y'y", "U" ], "y''U", [ "y'y'y", "U" ],
642             "y'Y", [ "y'y", "Y" ], "y''Y", [ "y'y'y", "Y" ],
643              
644             "y'_I", [ "y'y", "_I" ], "y''_I", [ "y'y'y", "_I" ],
645              
646             "y'_U", [ "", "y'U" ], "y''_U", [ "", "y''U" ],
647             "y'_A", [ "", "y'Y" ], "y''_A", [ "", "y''Y" ],
648              
649             "U'A", [ "U'w", "A" ], "U''A", [ "U'w'w", "A" ],
650             "U'I", [ "U'y", "I" ], "U''I", [ "U'y'y", "I" ],
651             "U'U", [ "U'w", "U" ], "U''U", [ "U'w'w", "U" ],
652             "U'Y", [ "U'w", "Y" ], "U''Y", [ "U'w'w", "Y" ],
653              
654             "U'_I", [ "U'y", "_I" ], "U''_I", [ "U'y'y", "_I" ],
655              
656             "U'_U", [ "", "U'U" ], "U''_U", [ "", "U''U" ],
657             "U'_A", [ "", "U'Y" ], "U''_A", [ "", "U''Y" ],
658              
659             "uw'A", [ "uw'w", "A" ], "uw''A", [ "uw'w'w", "A" ],
660             "uw'I", [ "uw'y", "I" ], "uw''I", [ "uw'y'y", "I" ],
661             "uw'U", [ "uw'w", "U" ], "uw''U", [ "uw'w'w", "U" ],
662             "uw'Y", [ "uw'w", "Y" ], "uw''Y", [ "uw'w'w", "Y" ],
663              
664             "uw'_I", [ "uw'y", "_I" ], "uw''_I", [ "uw'y'y", "_I" ],
665              
666             "uw'_U", [ "", "uw'U" ], "uw''_U", [ "", "uw''U" ],
667             "uw'_A", [ "", "uw'Y" ], "uw''_A", [ "", "uw''Y" ],
668              
669             ( $option{'non-quoting'} ? () : (
670              
671             "a'\"A", [ "a'", "A" ], # unclear ^^
672             "a'\"I", [ "a'y\"", "I" ], "a''\"I", [ "a'y'y\"", "I" ],
673             "a'\"U", [ "a'w\"", "U" ], "a''\"U", [ "a'w'w\"", "U" ],
674              
675             "a'\"_I", [ "a'y\"", "_I" ], "a''\"_I", [ "a'y'y\"", "_I" ],
676              
677             "u'\"I", [ "u'y\"", "I" ], "u''\"I", [ "u'y'y\"", "I" ],
678              
679             "u'\"_I", [ "u'y\"", "_I" ], "u''\"_I", [ "u'y'y\"", "_I" ],
680              
681             "I'\"aN", [ "I'y\"", "aN" ], "I''\"aN", [ "I'y'y\"", "aN" ],
682             "y'\"aN", [ "y'y\"", "aN" ], "y''\"aN", [ "y'y'y\"", "aN" ],
683              
684             "y\"'\"aN", [ "y\"'y\"", "aN" ], "y\"''\"aN", [ "y\"'y'y\"", "aN" ],
685             "y\"'aN", [ "y\"'y", "aN" ], "y\"''aN", [ "y\"'y'y", "aN" ],
686              
687             "A'\"A", [ "A'|\"", "A" ], "A''\"A", [ "A'|'|\"", "A" ],
688             "A'\"I", [ "A'y\"", "I" ], "A''\"I", [ "A'y'y\"", "I" ],
689             "A'\"U", [ "A'w\"", "U" ], "A''\"U", [ "A'w'w\"", "U" ],
690             "A'\"Y", [ "A'|\"", "Y" ], "A''\"Y", [ "A'|'|\"", "Y" ],
691              
692             "A'\"_I", [ "A'y\"", "_I" ], "A''\"_I", [ "A'y'y\"", "_I" ],
693              
694             "A'\"_U", [ "", "A'\"U" ], "A''\"_U", [ "", "A''\"U" ],
695             "A'\"_A", [ "", "A'\"Y" ], "A''\"_A", [ "", "A''\"Y" ],
696              
697             "I'\"A", [ "I'y\"", "A" ], "I''\"A", [ "I'y'y\"", "A" ],
698             "I'\"I", [ "I'y\"", "I" ], "I''\"I", [ "I'y'y\"", "I" ],
699             "I'\"U", [ "I'y\"", "U" ], "I''\"U", [ "I'y'y\"", "U" ],
700             "I'\"Y", [ "I'y\"", "Y" ], "I''\"Y", [ "I'y'y\"", "Y" ],
701              
702             "I'\"_I", [ "I'y\"", "_I" ], "I''\"_I", [ "I'y'y\"", "_I" ],
703              
704             "I'\"_U", [ "", "I'\"U" ], "I''\"_U", [ "", "I''\"U" ],
705             "I'\"_A", [ "", "I'\"Y" ], "I''\"_A", [ "", "I''\"Y" ],
706              
707             "y'\"A", [ "y'y\"", "A" ], "y''\"A", [ "y'y'y\"", "A" ],
708             "y'\"I", [ "y'y\"", "I" ], "y''\"I", [ "y'y'y\"", "I" ],
709             "y'\"U", [ "y'y\"", "U" ], "y''\"U", [ "y'y'y\"", "U" ],
710             "y'\"Y", [ "y'y\"", "Y" ], "y''\"Y", [ "y'y'y\"", "Y" ],
711              
712             "y'\"_I", [ "y'y\"", "_I" ], "y''\"_I", [ "y'y'y\"", "_I" ],
713              
714             "y'\"_U", [ "", "y'\"U" ], "y''\"_U", [ "", "y''\"U" ],
715             "y'\"_A", [ "", "y'\"Y" ], "y''\"_A", [ "", "y''\"Y" ],
716              
717             "y\"'\"A", [ "y\"'y\"", "A" ], "y\"''\"A", [ "y\"'y'y\"", "A" ],
718             "y\"'\"I", [ "y\"'y\"", "I" ], "y\"''\"I", [ "y\"'y'y\"", "I" ],
719             "y\"'\"U", [ "y\"'y\"", "U" ], "y\"''\"U", [ "y\"'y'y\"", "U" ],
720             "y\"'\"Y", [ "y\"'y\"", "Y" ], "y\"''\"Y", [ "y\"'y'y\"", "Y" ],
721              
722             "y\"'\"_I", [ "y\"'y\"", "_I" ], "y\"''\"_I", [ "y\"'y'y\"", "_I" ],
723              
724             "y\"'\"_U", [ "", "y\"'\"U" ], "y\"''\"_U", [ "", "y\"''\"U" ],
725             "y\"'\"_A", [ "", "y\"'\"Y" ], "y\"''\"_A", [ "", "y\"''\"Y" ],
726              
727             "y\"'A", [ "y\"'y", "A" ], "y\"''A", [ "y\"'y'y", "A" ],
728             "y\"'I", [ "y\"'y", "I" ], "y\"''I", [ "y\"'y'y", "I" ],
729             "y\"'U", [ "y\"'y", "U" ], "y\"''U", [ "y\"'y'y", "U" ],
730             "y\"'Y", [ "y\"'y", "Y" ], "y\"''Y", [ "y\"'y'y", "Y" ],
731              
732             "y\"'_I", [ "y\"'y", "_I" ], "y\"''_I", [ "y\"'y'y", "_I" ],
733              
734             "y\"'_U", [ "", "y\"'U" ], "y\"''_U", [ "", "y\"''U" ],
735             "y\"'_A", [ "", "y\"'Y" ], "y\"''_A", [ "", "y\"''Y" ],
736              
737             "U'\"A", [ "U'w\"", "A" ], "U''\"A", [ "U'w'w\"", "A" ],
738             "U'\"I", [ "U'y\"", "I" ], "U''\"I", [ "U'y'y\"", "I" ],
739             "U'\"U", [ "U'w\"", "U" ], "U''\"U", [ "U'w'w\"", "U" ],
740             "U'\"Y", [ "U'w\"", "Y" ], "U''\"Y", [ "U'w'w\"", "Y" ],
741              
742             "U'\"_I", [ "U'y\"", "_I" ], "U''\"_I", [ "U'y'y\"", "_I" ],
743              
744             "U'\"_U", [ "", "U'\"U" ], "U''\"_U", [ "", "U''\"U" ],
745             "U'\"_A", [ "", "U'\"Y" ], "U''\"_A", [ "", "U''\"Y" ],
746              
747             "uw'\"A", [ "uw'w\"", "A" ], "uw''\"A", [ "uw'w'w\"", "A" ],
748             "uw'\"I", [ "uw'y\"", "I" ], "uw''\"I", [ "uw'y'y\"", "I" ],
749             "uw'\"U", [ "uw'w\"", "U" ], "uw''\"U", [ "uw'w'w\"", "U" ],
750             "uw'\"Y", [ "uw'w\"", "Y" ], "uw''\"Y", [ "uw'w'w\"", "Y" ],
751              
752             "uw'\"_I", [ "uw'y\"", "_I" ], "uw''\"_I", [ "uw'y'y\"", "_I" ],
753              
754             "uw'\"_U", [ "", "uw'\"U" ], "uw''\"_U", [ "", "uw''\"U" ],
755             "uw'\"_A", [ "", "uw'\"Y" ], "uw''\"_A", [ "", "uw''\"Y" ],
756              
757             ) ),
758              
759             (
760             map { # doubled
761              
762 0           "a'i" . $_, [ "a'y", "i" . $_ ], "a''i" . $_, [ "a'y'y", "i" . $_ ],
763             "a'u" . $_, [ "a'w", "u" . $_ ], "a''u" . $_, [ "a'w'w", "u" . $_ ],
764             "u'i" . $_, [ "u'y", "i" . $_ ], "u''i" . $_, [ "u'y'y", "i" . $_ ],
765              
766             "A'a" . $_, [ "A'|", "a" . $_ ], "A''a" . $_, [ "A'|'|", "a" . $_ ],
767             "A'i" . $_, [ "A'y", "i" . $_ ], "A''i" . $_, [ "A'y'y", "i" . $_ ],
768             "A'u" . $_, [ "A'w", "u" . $_ ], "A''u" . $_, [ "A'w'w", "u" . $_ ],
769              
770             "I'a" . $_, [ "I'y", "a" . $_ ], "I''a" . $_, [ "I'y'y", "a" . $_ ],
771             "I'i" . $_, [ "I'y", "i" . $_ ], "I''i" . $_, [ "I'y'y", "i" . $_ ],
772             "I'u" . $_, [ "I'y", "u" . $_ ], "I''u" . $_, [ "I'y'y", "u" . $_ ],
773              
774             "y'a" . $_, [ "y'y", "a" . $_ ], "y''a" . $_, [ "y'y'y", "a" . $_ ],
775             "y'i" . $_, [ "y'y", "i" . $_ ], "y''i" . $_, [ "y'y'y", "i" . $_ ],
776             "y'u" . $_, [ "y'y", "u" . $_ ], "y''u" . $_, [ "y'y'y", "u" . $_ ],
777              
778             "U'a" . $_, [ "U'w", "a" . $_ ], "U''a" . $_, [ "U'w'w", "a" . $_ ],
779             "U'i" . $_, [ "U'y", "i" . $_ ], "U''i" . $_, [ "U'y'y", "i" . $_ ],
780             "U'u" . $_, [ "U'w", "u" . $_ ], "U''u" . $_, [ "U'w'w", "u" . $_ ],
781              
782             "uw'a" . $_, [ "uw'w", "a" . $_ ], "uw''a" . $_, [ "uw'w'w", "a" . $_ ],
783             "uw'i" . $_, [ "uw'y", "i" . $_ ], "uw''i" . $_, [ "uw'y'y", "i" . $_ ],
784             "uw'u" . $_, [ "uw'w", "u" . $_ ], "uw''u" . $_, [ "uw'w'w", "u" . $_ ],
785              
786             ( $option{'non-quoting'} ? () : (
787              
788             "a'\"i" . $_, [ "a'y\"", "i" . $_ ], "a''\"i" . $_, [ "a'y'y\"", "i" . $_ ],
789             "a'\"u" . $_, [ "a'w\"", "u" . $_ ], "a''\"u" . $_, [ "a'w'w\"", "u" . $_ ],
790             "u'\"i" . $_, [ "u'y\"", "i" . $_ ], "u''\"i" . $_, [ "u'y'y\"", "i" . $_ ],
791              
792             "A'\"a" . $_, [ "A'|\"", "a" . $_ ], "A''\"a" . $_, [ "A'|'|\"", "a" . $_ ],
793             "A'\"i" . $_, [ "A'y\"", "i" . $_ ], "A''\"i" . $_, [ "A'y'y\"", "i" . $_ ],
794             "A'\"u" . $_, [ "A'w\"", "u" . $_ ], "A''\"u" . $_, [ "A'w'w\"", "u" . $_ ],
795              
796             "I'\"a" . $_, [ "I'y\"", "a" . $_ ], "I''\"a" . $_, [ "I'y'y\"", "a" . $_ ],
797             "I'\"i" . $_, [ "I'y\"", "i" . $_ ], "I''\"i" . $_, [ "I'y'y\"", "i" . $_ ],
798             "I'\"u" . $_, [ "I'y\"", "u" . $_ ], "I''\"u" . $_, [ "I'y'y\"", "u" . $_ ],
799              
800             "y'\"a" . $_, [ "y'y\"", "a" . $_ ], "y''\"a" . $_, [ "y'y'y\"", "a" . $_ ],
801             "y'\"i" . $_, [ "y'y\"", "i" . $_ ], "y''\"i" . $_, [ "y'y'y\"", "i" . $_ ],
802             "y'\"u" . $_, [ "y'y\"", "u" . $_ ], "y''\"u" . $_, [ "y'y'y\"", "u" . $_ ],
803              
804             "y\"'\"a" . $_, [ "y\"'y\"", "a" . $_ ], "y\"''\"a" . $_, [ "y\"'y'y\"", "a" . $_ ],
805             "y\"'\"i" . $_, [ "y\"'y\"", "i" . $_ ], "y\"''\"i" . $_, [ "y\"'y'y\"", "i" . $_ ],
806             "y\"'\"u" . $_, [ "y\"'y\"", "u" . $_ ], "y\"''\"u" . $_, [ "y\"'y'y\"", "u" . $_ ],
807              
808             "y\"'a" . $_, [ "y\"'y", "a" . $_ ], "y\"''a" . $_, [ "y\"'y'y", "a" . $_ ],
809             "y\"'i" . $_, [ "y\"'y", "i" . $_ ], "y\"''i" . $_, [ "y\"'y'y", "i" . $_ ],
810             "y\"'u" . $_, [ "y\"'y", "u" . $_ ], "y\"''u" . $_, [ "y\"'y'y", "u" . $_ ],
811              
812             "U'\"a" . $_, [ "U'w\"", "a" . $_ ], "U''\"a" . $_, [ "U'w'w\"", "a" . $_ ],
813             "U'\"i" . $_, [ "U'y\"", "i" . $_ ], "U''\"i" . $_, [ "U'y'y\"", "i" . $_ ],
814             "U'\"u" . $_, [ "U'w\"", "u" . $_ ], "U''\"u" . $_, [ "U'w'w\"", "u" . $_ ],
815              
816             "uw'\"a" . $_, [ "uw'w\"", "a" . $_ ], "uw''\"a" . $_, [ "uw'w'w\"", "a" . $_ ],
817             "uw'\"i" . $_, [ "uw'y\"", "i" . $_ ], "uw''\"i" . $_, [ "uw'y'y\"", "i" . $_ ],
818             "uw'\"u" . $_, [ "uw'w\"", "u" . $_ ], "uw''\"u" . $_, [ "uw'w'w\"", "u" . $_ ],
819              
820             ) ),
821              
822             } "'", @scope, "y", "T", "H", "W"
823             ),
824              
825             (
826             map { # doubled
827              
828 0 0         my $fix = $_;
829              
830 0 0         $_ . "'A", [ $_ . "'", "A" ], $_ . "''A", [ $_ . "'a'a", "A" ],
831             $_ . "'I", [ $_ . "'y", "I" ], $_ . "''I", [ $_ . "'y'y", "I" ],
832             $_ . "'U", [ $_ . "'w", "U" ], $_ . "''U", [ $_ . "'w'w", "U" ],
833              
834             $_ . "'Y", [ $_ . "'a", "Y" ], $_ . "''Y", [ $_ . "'a'a", "Y" ],
835              
836             $_ . "'aNY", [ $_ . "'a", "aNY" ], $_ . "''aNY", [ $_ . "'a'a", "aNY" ],
837              
838             $_ . "'_I", [ $_ . "'y", "_I" ], $_ . "''_I", [ $_ . "'y'y", "_I" ],
839              
840             $_ . "'_U", [ "", $_ . "'U" ], $_ . "''_U", [ "", $_ . "''U" ],
841              
842             ( $option{'non-quoting'} ? () : (
843              
844             $_ . "'\"A", [ $_ . "'", "A" ], $_ . "''\"A", [ $_ . "'a'a\"", "A" ],
845             $_ . "'\"I", [ $_ . "'y\"", "I" ], $_ . "''\"I", [ $_ . "'y'y\"", "I" ],
846             $_ . "'\"U", [ $_ . "'w\"", "U" ], $_ . "''\"U", [ $_ . "'w'w\"", "U" ],
847              
848             $_ . "'\"Y", [ $_ . "'a\"", "Y" ], $_ . "''\"Y", [ $_ . "'a'a\"", "Y" ],
849              
850             $_ . "'\"aNY", [ $_ . "'a\"", "aNY" ], $_ . "''\"aNY", [ $_ . "'a'a\"", "aNY" ],
851              
852             $_ . "'\"_I", [ $_ . "'y\"", "_I" ], $_ . "''\"_I", [ $_ . "'y'y\"", "_I" ],
853              
854             $_ . "'\"_U", [ "", $_ . "'\"U" ], $_ . "''\"_U", [ "", $_ . "''\"U" ],
855              
856             ) ),
857              
858             map { # doubled
859              
860 0 0         $fix . "'a" . $_, [ $fix . "'a", "a" . $_ ], $fix . "''a" . $_, [ $fix . "'a'a", "a" . $_ ],
861             $fix . "'i" . $_, [ $fix . "'y", "i" . $_ ], $fix . "''i" . $_, [ $fix . "'y'y", "i" . $_ ],
862             $fix . "'u" . $_, [ $fix . "'w", "u" . $_ ], $fix . "''u" . $_, [ $fix . "'w'w", "u" . $_ ],
863              
864             ( $option{'non-quoting'} ? () : (
865              
866             $fix . "'\"a" . $_, [ $fix . "'a\"", "a" . $_ ], $fix . "''\"a" . $_, [ $fix . "'a'a\"", "a" . $_ ],
867             $fix . "'\"i" . $_, [ $fix . "'y\"", "i" . $_ ], $fix . "''\"i" . $_, [ $fix . "'y'y\"", "i" . $_ ],
868             $fix . "'\"u" . $_, [ $fix . "'w\"", "u" . $_ ], $fix . "''\"u" . $_, [ $fix . "'w'w\"", "u" . $_ ],
869              
870             ) ),
871              
872             } "'", @scope, "y", "T", "H", "W"
873              
874             } @scope, $option{'non-quoting'} ? () : "\"" # quoted included
875             ),
876              
877             "T'A", [ "t'", "A" ], "T''A", [ "t'a'a", "A" ],
878             "T'I", [ "t'y", "I" ], "T''I", [ "t'y'y", "I" ],
879             "T'U", [ "t'w", "U" ], "T''U", [ "t'w'w", "U" ],
880              
881             "T'_I", [ "t'y", "_I" ], "T''_I", [ "t'y'y", "_I" ],
882              
883             "T'_U", [ "", "T'U" ], "T''_U", [ "", "T''U" ],
884              
885             ( $option{'non-quoting'} ? () : (
886              
887             "T'\"A", [ "t'", "A" ], "T''\"A", [ "t'a'a\"", "A" ],
888             "T'\"I", [ "t'y\"", "I" ], "T''\"I", [ "t'y'y\"", "I" ],
889             "T'\"U", [ "t'w\"", "U" ], "T''\"U", [ "t'w'w\"", "U" ],
890              
891             "T'\"_I", [ "t'y\"", "_I" ], "T''\"_I", [ "t'y'y\"", "_I" ],
892              
893             "T'\"_U", [ "", "T'\"U" ], "T''\"_U", [ "", "T''\"U" ],
894              
895             ) ),
896              
897             (
898             map { # doubled
899              
900 0 0         "T'a" . $_, [ "t'a", "a" . $_ ], "T''a" . $_, [ "t'a'a", "a" . $_ ],
    0          
    0          
    0          
    0          
    0          
    0          
901             "T'i" . $_, [ "t'y", "i" . $_ ], "T''i" . $_, [ "t'y'y", "i" . $_ ],
902             "T'u" . $_, [ "t'w", "u" . $_ ], "T''u" . $_, [ "t'w'w", "u" . $_ ],
903              
904             ( $option{'non-quoting'} ? () : (
905              
906             "T'\"a" . $_, [ "t'a\"", "a" . $_ ], "T''\"a" . $_, [ "t'a'a\"", "a" . $_ ],
907             "T'\"i" . $_, [ "t'y\"", "i" . $_ ], "T''\"i" . $_, [ "t'y'y\"", "i" . $_ ],
908             "T'\"u" . $_, [ "t'w\"", "u" . $_ ], "T''\"u" . $_, [ "t'w'w\"", "u" . $_ ],
909              
910             ) ),
911              
912             } "'", @scope, "y" # "T", "H", "W"
913             ),
914              
915             );
916              
917              
918 0           $decoder->[1] = Encode::Mapper->compile (
919              
920             [
921             'others' => undef,
922             'silent' => 0,
923             ],
924              
925             # non-exciting entities
926              
927             "\x09", "\x09",
928             "\x0A", "\x0A",
929             "\x0D", "\x0D",
930              
931             " ", " ",
932             ".", ".",
933             ":", ":",
934             "!", "!",
935              
936             "/", "/",
937             "\\", "\\",
938              
939             ",", "\x{060C}", # "\xD8\x8C" right-to-left-comma
940             ";", "\x{061B}", # "\xD8\x9B" right-to-left-semicolon
941             "?", "\x{061F}", # "\xD8\x9F" right-to-left-question-mark
942              
943             "--", "\x{0640}", # "\xD9\x80" ta.twiil
944              
945             (
946             map {
947              
948 0           "" . $_, chr 0x0660 + $_,
949              
950             } 0 .. 9
951             ),
952              
953             # improper auxiliary vowels -- the case of conditioned deletion
954              
955             "-a", "",
956             "-u", "",
957             "-i", "",
958              
959             (
960             map {
961              
962 0           "-a" . $_->[0], [ "", "a" . $_->[0] ],
963             "-i" . $_->[0], [ "", "i" . $_->[0] ],
964             "-u" . $_->[0], [ "", "u" . $_->[0] ],
965              
966             } @sunny, @moony, @taaaa, $empty[0]
967             ),
968              
969             # non-voweled/sukuuned sunnies and moonies
970             (
971             map {
972              
973 0           my $x = 1 + $_;
974 0           my $y = "\x{0651}" x $_; # "\xD9\x91" ^sadda
975              
976 0           map {
977              
978 0           my $fix = $_;
979              
980 0 0         $_->[0] x $x, $_->[1] . $y . "\x{0652}", # "\xD9\x92" sukuun
    0          
981              
982             ( $option{'non-refined'} ? () : (
983              
984             $_->[0] x $x . "-a", $_->[1] . $y . "\x{064E}",
985             $_->[0] x $x . "-u", $_->[1] . $y . "\x{064F}",
986             $_->[0] x $x . "-i", $_->[1] . $y . "\x{0650}",
987              
988             $_->[0] x $x . "-A", $_->[1] . $y . "\x{064E}\x{0627}",
989             $_->[0] x $x . "-Y", $_->[1] . $y . "\x{064E}\x{0649}",
990              
991             $_->[0] x $x . "-U", $_->[1] . $y . "\x{064F}\x{0648}",
992             $_->[0] x $x . "-I", $_->[1] . $y . "\x{0650}\x{064A}",
993              
994             $_->[0] x $x . "-aN", $_->[1] . $y . "\x{064B}" . ( $_->[0] eq "'a" ? "" : "\x{0627}" ),
995             $_->[0] x $x . "-uN", $_->[1] . $y . "\x{064C}",
996             $_->[0] x $x . "-iN", $_->[1] . $y . "\x{064D}",
997              
998             $_->[0] x $x . "-aNA", $_->[1] . $y . "\x{064B}\x{0627}",
999             $_->[0] x $x . "-uNA", $_->[1] . $y . "\x{064C}\x{0627}",
1000             $_->[0] x $x . "-iNA", $_->[1] . $y . "\x{064D}\x{0627}",
1001              
1002             $_->[0] x $x . "-aNY", $_->[1] . $y . "\x{064B}\x{0649}",
1003             $_->[0] x $x . "-uNY", $_->[1] . $y . "\x{064C}\x{0649}",
1004             $_->[0] x $x . "-iNY", $_->[1] . $y . "\x{064D}\x{0649}",
1005              
1006             $_->[0] x $x . "-aNU", $_->[1] . $y . "\x{064B}\x{0648}",
1007             $_->[0] x $x . "-uNU", $_->[1] . $y . "\x{064C}\x{0648}",
1008             $_->[0] x $x . "-iNU", $_->[1] . $y . "\x{064D}\x{0648}",
1009              
1010             ) ),
1011              
1012             ( $option{'non-quoting'} ? () : (
1013              
1014             $_->[0] x $x . "\"", $_->[1] . $y . "\"\x{0652}", # "\xD9\x92" sukuun
1015              
1016             ( $option{'non-refined'} ? () : (
1017              
1018             $_->[0] x $x . "-\"a", $_->[1] . $y . "\"\x{064E}",
1019             $_->[0] x $x . "-\"u", $_->[1] . $y . "\"\x{064F}",
1020             $_->[0] x $x . "-\"i", $_->[1] . $y . "\"\x{0650}",
1021              
1022             $_->[0] x $x . "-\"A", $_->[1] . $y . "\"\x{064E}\x{0627}",
1023             $_->[0] x $x . "-\"Y", $_->[1] . $y . "\"\x{064E}\x{0649}",
1024              
1025             $_->[0] x $x . "-\"U", $_->[1] . $y . "\"\x{064F}\x{0648}",
1026             $_->[0] x $x . "-\"I", $_->[1] . $y . "\"\x{0650}\x{064A}",
1027              
1028             $_->[0] x $x . "-\"aN", $_->[1] . $y . "\"\x{064B}" . ( $_->[0] eq "'a" ? "" : "\x{0627}" ),
1029             $_->[0] x $x . "-\"uN", $_->[1] . $y . "\"\x{064C}",
1030             $_->[0] x $x . "-\"iN", $_->[1] . $y . "\"\x{064D}",
1031              
1032             $_->[0] x $x . "-\"aNA", $_->[1] . $y . "\"\x{064B}\x{0627}",
1033             $_->[0] x $x . "-\"uNA", $_->[1] . $y . "\"\x{064C}\x{0627}",
1034             $_->[0] x $x . "-\"iNA", $_->[1] . $y . "\"\x{064D}\x{0627}",
1035              
1036             $_->[0] x $x . "-\"aNY", $_->[1] . $y . "\"\x{064B}\x{0649}",
1037             $_->[0] x $x . "-\"uNY", $_->[1] . $y . "\"\x{064C}\x{0649}",
1038             $_->[0] x $x . "-\"iNY", $_->[1] . $y . "\"\x{064D}\x{0649}",
1039              
1040             $_->[0] x $x . "-\"aNU", $_->[1] . $y . "\"\x{064B}\x{0648}",
1041             $_->[0] x $x . "-\"uNU", $_->[1] . $y . "\"\x{064C}\x{0648}",
1042             $_->[0] x $x . "-\"iNU", $_->[1] . $y . "\"\x{064D}\x{0648}",
1043              
1044             ) ),
1045              
1046             ) ),
1047              
1048             map {
1049              
1050 0 0         ( $option{'non-refined'} ? () : (
    0          
    0          
    0          
    0          
1051              
1052             $fix->[0] x $x . "-a" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "a" . $_->[0] ],
1053             $fix->[0] x $x . "-u" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "u" . $_->[0] ],
1054             $fix->[0] x $x . "-i" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "i" . $_->[0] ],
1055              
1056             $fix->[0] x $x . "-A" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "A" . $_->[0] ],
1057             $fix->[0] x $x . "-Y" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "Y" . $_->[0] ],
1058              
1059             $fix->[0] x $x . "-U" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "U" . $_->[0] ],
1060             $fix->[0] x $x . "-I" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "I" . $_->[0] ],
1061              
1062             ( $option{'non-quoting'} ? () : (
1063              
1064             $fix->[0] x $x . "-\"a" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "a" . $_->[0] ],
1065             $fix->[0] x $x . "-\"u" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "u" . $_->[0] ],
1066             $fix->[0] x $x . "-\"i" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "i" . $_->[0] ],
1067              
1068             $fix->[0] x $x . "-\"A" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "A" . $_->[0] ],
1069             $fix->[0] x $x . "-\"Y" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "Y" . $_->[0] ],
1070              
1071             $fix->[0] x $x . "-\"U" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "U" . $_->[0] ],
1072             $fix->[0] x $x . "-\"I" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "I" . $_->[0] ],
1073              
1074             ) ),
1075              
1076             ) ),
1077              
1078             } @sunny, @moony, @taaaa, $empty[0]
1079              
1080             } @sunny, @moony[1 .. $#moony], $empty[0] # $moony[0] excluded as long as is unclear ^^
1081              
1082             } 0, 1
1083             ),
1084              
1085             $moony[0]->[0], $moony[0]->[1], # now necessary of course ^^
1086              
1087             # voweled/non-sukuuned sunnies and moonies
1088             (
1089             map {
1090              
1091 0           my $x = 1 + $_;
1092 0           my $y = "\x{0651}" x $_; # "\xD9\x91" ^sadda
1093              
1094 0           map {
1095              
1096 0           my $fix = $_;
1097              
1098 0 0         $_->[0] x $x . "a", $_->[1] . $y . "\x{064E}",
1099             $_->[0] x $x . "u", $_->[1] . $y . "\x{064F}",
1100             $_->[0] x $x . "i", $_->[1] . $y . "\x{0650}",
1101              
1102             $_->[0] x $x . "_a", $_->[1] . $y . "\x{0670}",
1103              
1104             ( $option{'non-refined'} ? () : (
1105              
1106             $_->[0] x $x . "_u", $_->[1] . $y . "\x{0657}",
1107             $_->[0] x $x . "_i", $_->[1] . $y . "\x{0656}",
1108              
1109             $_->[0] x $x . "_aA", $_->[1] . $y . "\x{0670}\x{0627}",
1110             $_->[0] x $x . "_aY", $_->[1] . $y . "\x{0670}\x{0649}",
1111             $_->[0] x $x . "_aU", $_->[1] . $y . "\x{0670}\x{0648}",
1112             $_->[0] x $x . "_aI", $_->[1] . $y . "\x{0670}\x{064A}",
1113              
1114             ) ),
1115              
1116             $_->[0] x $x . "A", $_->[1] . $y . "\x{064E}\x{0627}",
1117             $_->[0] x $x . "Y", $_->[1] . $y . "\x{064E}\x{0649}",
1118              
1119             $_->[0] x $x . "_I", $_->[1] . $y . "\x{0650}\x{0627}",
1120              
1121             $_->[0] x $x . "U", $_->[1] . $y . "\x{064F}\x{0648}",
1122             $_->[0] x $x . "I", $_->[1] . $y . "\x{0650}\x{064A}",
1123              
1124             $_->[0] x $x . "Uw", [ $_->[1] . $y . "\x{064F}", "ww" ],
1125             $_->[0] x $x . "Iy", [ $_->[1] . $y . "\x{0650}", "yy" ],
1126              
1127             ( $option{'non-refined'} ? () : (
1128              
1129             $_->[0] x $x . "^A", $_->[1] . $y . "\x{064F}\x{0627}\x{0653}",
1130             $_->[0] x $x . "^U", $_->[1] . $y . "\x{064F}\x{0648}\x{0653}",
1131             $_->[0] x $x . "^I", $_->[1] . $y . "\x{0650}\x{064A}\x{0653}",
1132              
1133             $_->[0] x $x . "^Uw", [ $_->[1] . $y . "\x{064F}\x{0648}\x{0655}", "|" ], # roughly
1134             $_->[0] x $x . "^Iy", [ $_->[1] . $y . "\x{0650}\x{0649}\x{0655}", "|" ], # roughly
1135              
1136             ) ),
1137              
1138             $_->[0] x $x . "aa", [ "", $_->[0] x $x . "A" ],
1139             $_->[0] x $x . "uw", [ "", $_->[0] x $x . "U" ],
1140             $_->[0] x $x . "iy", [ "", $_->[0] x $x . "I" ],
1141              
1142             ( $option{'non-quoting'} ? () : (
1143              
1144             $_->[0] x $x . "\"a", $_->[1] . $y . "\"\x{064E}",
1145             $_->[0] x $x . "\"u", $_->[1] . $y . "\"\x{064F}",
1146             $_->[0] x $x . "\"i", $_->[1] . $y . "\"\x{0650}",
1147              
1148             $_->[0] x $x . "\"_a", $_->[1] . $y . "\"\x{0670}",
1149              
1150             ( $option{'non-refined'} ? () : (
1151              
1152             $_->[0] x $x . "\"_u", $_->[1] . $y . "\"\x{0657}",
1153             $_->[0] x $x . "\"_i", $_->[1] . $y . "\"\x{0656}",
1154              
1155             $_->[0] x $x . "\"_aA", $_->[1] . $y . "\"\x{0670}\x{0627}",
1156             $_->[0] x $x . "\"_aY", $_->[1] . $y . "\"\x{0670}\x{0649}",
1157             $_->[0] x $x . "\"_aU", $_->[1] . $y . "\"\x{0670}\x{0648}",
1158             $_->[0] x $x . "\"_aI", $_->[1] . $y . "\"\x{0670}\x{064A}",
1159              
1160             ) ),
1161              
1162             $_->[0] x $x . "\"A", $_->[1] . $y . "\"\x{064E}\x{0627}",
1163             $_->[0] x $x . "\"Y", $_->[1] . $y . "\"\x{064E}\x{0649}",
1164              
1165             $_->[0] x $x . "\"A\"", $_->[1] . $y . "\"\x{064E}\x{0627}\"\x{0652}",
1166             $_->[0] x $x . "\"Y\"", $_->[1] . $y . "\"\x{064E}\x{0649}\"\x{0652}",
1167              
1168             $_->[0] x $x . "A\"", $_->[1] . $y . "\x{064E}\x{0627}\"\x{0652}",
1169             $_->[0] x $x . "Y\"", $_->[1] . $y . "\x{064E}\x{0649}\"\x{0652}",
1170              
1171             $_->[0] x $x . "\"_I", $_->[1] . $y . "\"\x{0650}\x{0627}",
1172             $_->[0] x $x . "\"_I\"", $_->[1] . $y . "\"\x{0650}\x{0627}\"\x{0652}",
1173             $_->[0] x $x . "_I\"", $_->[1] . $y . "\x{0650}\x{0627}\"\x{0652}",
1174              
1175             $_->[0] x $x . "\"U", $_->[1] . $y . "\"\x{064F}\x{0648}",
1176             $_->[0] x $x . "\"I", $_->[1] . $y . "\"\x{0650}\x{064A}",
1177              
1178             $_->[0] x $x . "\"U\"", $_->[1] . $y . "\"\x{064F}\x{0648}\"\x{0652}",
1179             $_->[0] x $x . "\"I\"", $_->[1] . $y . "\"\x{0650}\x{064A}\"\x{0652}",
1180              
1181             $_->[0] x $x . "U\"", $_->[1] . $y . "\x{064F}\x{0648}\"\x{0652}",
1182             $_->[0] x $x . "I\"", $_->[1] . $y . "\x{0650}\x{064A}\"\x{0652}",
1183              
1184             $_->[0] x $x . "\"Uw", [ $_->[1] . $y . "\"\x{064F}", "ww" ],
1185             $_->[0] x $x . "\"Iy", [ $_->[1] . $y . "\"\x{0650}", "yy" ],
1186              
1187             ( $option{'non-refined'} ? () : (
1188              
1189             $_->[0] x $x . "\"^A", $_->[1] . $y . "\"\x{064F}\x{0627}\x{0653}",
1190             $_->[0] x $x . "\"^U", $_->[1] . $y . "\"\x{064F}\x{0648}\x{0653}",
1191             $_->[0] x $x . "\"^I", $_->[1] . $y . "\"\x{0650}\x{064A}\x{0653}",
1192              
1193             $_->[0] x $x . "\"^Uw", [ $_->[1] . $y . "\"\x{064F}\x{0648}\x{0655}", "|" ], # roughly
1194             $_->[0] x $x . "\"^Iy", [ $_->[1] . $y . "\"\x{0650}\x{0649}\x{0655}", "|" ], # roughly
1195              
1196             ) ),
1197              
1198             $_->[0] x $x . "\"aa", [ "", $_->[0] x $x . "\"A" ],
1199             $_->[0] x $x . "\"uw", [ "", $_->[0] x $x . "\"U" ],
1200             $_->[0] x $x . "\"iy", [ "", $_->[0] x $x . "\"I" ],
1201              
1202             ) ),
1203              
1204             (
1205             map {
1206              
1207 0 0         $fix->[0] x $x . "uw" . $_, [ $fix->[1] . $y . "\x{064F}", "w" . $_ ],
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1208             $fix->[0] x $x . "iy" . $_, [ $fix->[1] . $y . "\x{0650}", "y" . $_ ],
1209              
1210             ( $option{'non-quoting'} ? () : (
1211              
1212             $fix->[0] x $x . "\"uw" . $_, [ $fix->[1] . $y . "\"\x{064F}", "w" . $_ ],
1213             $fix->[0] x $x . "\"iy" . $_, [ $fix->[1] . $y . "\"\x{0650}", "y" . $_ ],
1214              
1215             ) ),
1216              
1217             } "\"", qw "a u i A Y U I _I", $option{'non-refined'} ? () : qw "_a _u _i ^A ^U ^I"
1218             ),
1219              
1220             $_->[0] x $x . "_aA'|aN", $_->[1] . $y . "\x{0670}\x{0627}\x{0621}\x{064B}",
1221             $_->[0] x $x . "A'|aN", $_->[1] . $y . "\x{064E}\x{0627}\x{0621}\x{064B}",
1222              
1223             $_->[0] x $x . "aN", $_->[1] . $y . "\x{064B}" . ( $_->[0] eq "'a" ? "" : "\x{0627}" ),
1224             $_->[0] x $x . "uN", $_->[1] . $y . "\x{064C}",
1225             $_->[0] x $x . "iN", $_->[1] . $y . "\x{064D}",
1226              
1227             ( $option{'non-quoting'} ? () : (
1228              
1229             $_->[0] x $x . "\"_aA'|aN", $_->[1] . $y . "\"\x{0670}\x{0627}\x{0621}\x{064B}",
1230             $_->[0] x $x . "\"A'|aN", $_->[1] . $y . "\"\x{064E}\x{0627}\x{0621}\x{064B}",
1231              
1232             $_->[0] x $x . "\"_aA'|\"aN", $_->[1] . $y . "\"\x{0670}\x{0627}\x{0621}\"\x{064B}",
1233             $_->[0] x $x . "\"A'|\"aN", $_->[1] . $y . "\"\x{064E}\x{0627}\x{0621}\"\x{064B}",
1234              
1235             $_->[0] x $x . "_aA'|\"aN", $_->[1] . $y . "\x{0670}\x{0627}\x{0621}\"\x{064B}",
1236             $_->[0] x $x . "A'|\"aN", $_->[1] . $y . "\x{064E}\x{0627}\x{0621}\"\x{064B}",
1237              
1238             $_->[0] x $x . "\"A\"'|aN", $_->[1] . $y . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\x{064B}",
1239             $_->[0] x $x . "\"A\"'|\"aN", $_->[1] . $y . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}",
1240             $_->[0] x $x . "A\"'|\"aN", $_->[1] . $y . "\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}",
1241              
1242             $_->[0] x $x . "\"aN", $_->[1] . $y . "\"\x{064B}" . ( $_->[0] eq "'a" ? "" : "\x{0627}" ),
1243             $_->[0] x $x . "\"uN", $_->[1] . $y . "\"\x{064C}",
1244             $_->[0] x $x . "\"iN", $_->[1] . $y . "\"\x{064D}",
1245              
1246             ) ),
1247              
1248             } @sunny, @moony, $empty[0]
1249              
1250             } 0, 1
1251             ),
1252              
1253             # 'alif protected endings
1254             (
1255             map {
1256              
1257 0 0         my $x = 1 + $_;
1258 0           my $y = "\x{0651}" x $_; # "\xD9\x91" ^sadda
1259              
1260 0 0         map {
    0          
    0          
1261              
1262 0           $_->[0] x $x . "_aA'|aNA", $_->[1] . $y . "\x{0670}\x{0627}\x{0621}\x{064B}\x{0627}",
1263             $_->[0] x $x . "A'|aNA", $_->[1] . $y . "\x{064E}\x{0627}\x{0621}\x{064B}\x{0627}",
1264              
1265             $_->[0] x $x . "aNA", $_->[1] . $y . "\x{064B}\x{0627}",
1266             $_->[0] x $x . "aNY", $_->[1] . $y . "\x{064B}\x{0649}",
1267              
1268             ( $option{'non-refined'} ? () : (
1269              
1270             $_->[0] x $x . "uNA", $_->[1] . $y . "\x{064C}\x{0627}",
1271             $_->[0] x $x . "iNA", $_->[1] . $y . "\x{064D}\x{0627}",
1272              
1273             $_->[0] x $x . "uNY", $_->[1] . $y . "\x{064C}\x{0649}",
1274             $_->[0] x $x . "iNY", $_->[1] . $y . "\x{064D}\x{0649}",
1275              
1276             $_->[0] x $x . "aNU", $_->[1] . $y . "\x{064B}\x{0648}",
1277             $_->[0] x $x . "uNU", $_->[1] . $y . "\x{064C}\x{0648}",
1278             $_->[0] x $x . "iNU", $_->[1] . $y . "\x{064D}\x{0648}",
1279              
1280             $_->[0] x $x . "aW-a", $_->[1] . $y . "\x{064E}\x{0648}\x{064E}\x{0627}",
1281             $_->[0] x $x . "aW-u", $_->[1] . $y . "\x{064E}\x{0648}\x{064F}\x{0627}",
1282             $_->[0] x $x . "aW-i", $_->[1] . $y . "\x{064E}\x{0648}\x{0650}\x{0627}",
1283              
1284             ) ),
1285              
1286             $_->[0] x $x . "aW", $_->[1] . $y . "\x{064E}\x{0648}\x{0652}\x{0627}",
1287             $_->[0] x $x . "uW", $_->[1] . $y . "\x{064F}\x{0648}\x{0627}",
1288             $_->[0] x $x . "UW", $_->[1] . $y . "\x{064F}\x{0648}\x{0627}",
1289             $_->[0] x $x . "UA", $_->[1] . $y . "\x{064F}\x{0648}\x{0627}",
1290              
1291             ( $option{'non-quoting'} ? () : (
1292              
1293             $_->[0] x $x . "\"_aA'|aNA", $_->[1] . $y . "\"\x{0670}\x{0627}\x{0621}\x{064B}\x{0627}",
1294             $_->[0] x $x . "\"A'|aNA", $_->[1] . $y . "\"\x{064E}\x{0627}\x{0621}\x{064B}\x{0627}",
1295              
1296             $_->[0] x $x . "\"_aA'|\"aNA", $_->[1] . $y . "\"\x{0670}\x{0627}\x{0621}\"\x{064B}\x{0627}",
1297             $_->[0] x $x . "\"A'|\"aNA", $_->[1] . $y . "\"\x{064E}\x{0627}\x{0621}\"\x{064B}\x{0627}",
1298              
1299             $_->[0] x $x . "_aA'|\"aNA", $_->[1] . $y . "\x{0670}\x{0627}\x{0621}\"\x{064B}\x{0627}",
1300             $_->[0] x $x . "A'|\"aNA", $_->[1] . $y . "\x{064E}\x{0627}\x{0621}\"\x{064B}\x{0627}",
1301              
1302             $_->[0] x $x . "\"A\"'|aNA", $_->[1] . $y . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\x{064B}\x{0627}",
1303             $_->[0] x $x . "\"A\"'|\"aNA", $_->[1] . $y . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}\x{0627}",
1304             $_->[0] x $x . "A\"'|\"aNA", $_->[1] . $y . "\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}\x{0627}",
1305              
1306             $_->[0] x $x . "\"aNA", $_->[1] . $y . "\"\x{064B}\x{0627}",
1307             $_->[0] x $x . "\"aNY", $_->[1] . $y . "\"\x{064B}\x{0649}",
1308              
1309             ( $option{'non-refined'} ? () : (
1310              
1311             $_->[0] x $x . "\"uNA", $_->[1] . $y . "\"\x{064C}\x{0627}",
1312             $_->[0] x $x . "\"iNA", $_->[1] . $y . "\"\x{064D}\x{0627}",
1313              
1314             $_->[0] x $x . "\"uNY", $_->[1] . $y . "\"\x{064C}\x{0649}",
1315             $_->[0] x $x . "\"iNY", $_->[1] . $y . "\"\x{064D}\x{0649}",
1316              
1317             $_->[0] x $x . "\"aNU", $_->[1] . $y . "\"\x{064B}\x{0648}",
1318             $_->[0] x $x . "\"uNU", $_->[1] . $y . "\"\x{064C}\x{0648}",
1319             $_->[0] x $x . "\"iNU", $_->[1] . $y . "\"\x{064D}\x{0648}",
1320              
1321             $_->[0] x $x . "\"aW-a", $_->[1] . $y . "\"\x{064E}\x{0648}\x{064E}\x{0627}",
1322             $_->[0] x $x . "\"aW-u", $_->[1] . $y . "\"\x{064E}\x{0648}\x{064F}\x{0627}",
1323             $_->[0] x $x . "\"aW-i", $_->[1] . $y . "\"\x{064E}\x{0648}\x{0650}\x{0627}",
1324              
1325             $_->[0] x $x . "\"aW-\"a", $_->[1] . $y . "\"\x{064E}\x{0648}\"\x{064E}\x{0627}",
1326             $_->[0] x $x . "\"aW-\"u", $_->[1] . $y . "\"\x{064E}\x{0648}\"\x{064F}\x{0627}",
1327             $_->[0] x $x . "\"aW-\"i", $_->[1] . $y . "\"\x{064E}\x{0648}\"\x{0650}\x{0627}",
1328              
1329             $_->[0] x $x . "aW-\"a", $_->[1] . $y . "\x{064E}\x{0648}\"\x{064E}\x{0627}",
1330             $_->[0] x $x . "aW-\"u", $_->[1] . $y . "\x{064E}\x{0648}\"\x{064F}\x{0627}",
1331             $_->[0] x $x . "aW-\"i", $_->[1] . $y . "\x{064E}\x{0648}\"\x{0650}\x{0627}",
1332              
1333             $_->[0] x $x . "\"aW-\"", $_->[1] . $y . "\"\x{064E}\x{0648}\"\x{0652}\x{0627}",
1334             $_->[0] x $x . "aW-\"", $_->[1] . $y . "\x{064E}\x{0648}\"\x{0652}\x{0627}",
1335              
1336             ) ),
1337              
1338             $_->[0] x $x . "\"aW", $_->[1] . $y . "\"\x{064E}\x{0648}\x{0652}\x{0627}",
1339             $_->[0] x $x . "\"uW", $_->[1] . $y . "\"\x{064F}\x{0648}\x{0627}",
1340             $_->[0] x $x . "\"UW", $_->[1] . $y . "\"\x{064F}\x{0648}\x{0627}",
1341             $_->[0] x $x . "\"UA", $_->[1] . $y . "\"\x{064F}\x{0648}\x{0627}",
1342              
1343             ) ),
1344              
1345             } @sunny, @moony, $empty[0]
1346              
1347             } 0, 1
1348             ),
1349              
1350             # taa' marbuu.ta endings
1351             (
1352             map {
1353              
1354 0           $_->[0], $_->[1] . "\x{0652}", # "\xD9\x92" sukuun
1355              
1356             ( $option{'non-quoting'} ? () : (
1357              
1358             $_->[0] . "\"", $_->[1] . "\"\x{0652}", # "\xD9\x92" sukuun
1359              
1360             ) ),
1361              
1362             } @taaaa
1363             ),
1364              
1365             (
1366             map {
1367              
1368 0           my $fix = $_;
1369              
1370 0 0         $_->[0] . "a", $_->[1] . "\x{064E}",
    0          
1371             $_->[0] . "u", $_->[1] . "\x{064F}",
1372             $_->[0] . "i", $_->[1] . "\x{0650}",
1373              
1374             $_->[0] . "aN", $_->[1] . "\x{064B}",
1375             $_->[0] . "uN", $_->[1] . "\x{064C}",
1376             $_->[0] . "iN", $_->[1] . "\x{064D}",
1377              
1378             ( $option{'non-quoting'} ? () : (
1379              
1380             $_->[0] . "\"a", $_->[1] . "\"\x{064E}",
1381             $_->[0] . "\"u", $_->[1] . "\"\x{064F}",
1382             $_->[0] . "\"i", $_->[1] . "\"\x{0650}",
1383              
1384             $_->[0] . "\"aN", $_->[1] . "\"\x{064B}",
1385             $_->[0] . "\"uN", $_->[1] . "\"\x{064C}",
1386             $_->[0] . "\"iN", $_->[1] . "\"\x{064D}",
1387              
1388             ) ),
1389              
1390             # non-voweled/sukuuned
1391              
1392             ( $option{'non-refined'} ? () : (
1393              
1394             $_->[0] . "-a", $_->[1] . "\x{064E}",
1395             $_->[0] . "-u", $_->[1] . "\x{064F}",
1396             $_->[0] . "-i", $_->[1] . "\x{0650}",
1397              
1398             $_->[0] . "-aN", $_->[1] . "\x{064B}",
1399             $_->[0] . "-uN", $_->[1] . "\x{064C}",
1400             $_->[0] . "-iN", $_->[1] . "\x{064D}",
1401              
1402             ( $option{'non-quoting'} ? () : (
1403              
1404             $_->[0] . "-\"a", $_->[1] . "\"\x{064E}",
1405             $_->[0] . "-\"u", $_->[1] . "\"\x{064F}",
1406             $_->[0] . "-\"i", $_->[1] . "\"\x{0650}",
1407              
1408             $_->[0] . "-\"aN", $_->[1] . "\"\x{064B}",
1409             $_->[0] . "-\"uN", $_->[1] . "\"\x{064C}",
1410             $_->[0] . "-\"iN", $_->[1] . "\"\x{064D}",
1411              
1412             ) ),
1413              
1414             ) ),
1415              
1416             map {
1417              
1418 0 0         ( $option{'non-refined'} ? () : (
    0          
    0          
1419              
1420             $fix->[0] . "-a" . $_->[0], [ $fix->[1] . "\x{0652}", "a" . $_->[0] ],
1421             $fix->[0] . "-u" . $_->[0], [ $fix->[1] . "\x{0652}", "u" . $_->[0] ],
1422             $fix->[0] . "-i" . $_->[0], [ $fix->[1] . "\x{0652}", "i" . $_->[0] ],
1423              
1424             ( $option{'non-quoting'} ? () : (
1425              
1426             $fix->[0] . "-\"a" . $_->[0], [ $fix->[1] . "\x{0652}\"", "a" . $_->[0] ],
1427             $fix->[0] . "-\"u" . $_->[0], [ $fix->[1] . "\x{0652}\"", "u" . $_->[0] ],
1428             $fix->[0] . "-\"i" . $_->[0], [ $fix->[1] . "\x{0652}\"", "i" . $_->[0] ],
1429              
1430             ) ),
1431              
1432             ) ),
1433              
1434             } @sunny, @moony, $empty[0] # @taaaa
1435              
1436             } $taaaa[0]
1437             ),
1438              
1439             # definite article assimilation .. non-linguistic
1440              
1441             (
1442             map {
1443              
1444 0           $_->[0] . "-" . $_->[0], [ "\x{0644}", $_->[0] x 2 ],
1445             "l-" . $_->[0] x 2, [ "\x{0644}", $_->[0] x 2 ],
1446              
1447             } @sunny, @moony
1448             ),
1449              
1450             (
1451             map {
1452              
1453 0           my $fix = $_;
1454              
1455 0           "l" . $_ . "-all", [ "", "l" . ( $_ eq "" ? "|" : $_ ) . "ll" ],
1456             "l" . $_ . "-al-", [ "", "l" . ( $_ eq "" ? "|" : $_ ) . "l-" ],
1457              
1458             "l" . $_ . "-al-l", [ "", "l" . $_ . "-ll" ],
1459             "l" . $_ . "-al-ll", [ "", "l" . $_ . "-ll" ],
1460              
1461             map {
1462              
1463 0           "l" . $fix . "-a" . $_->[0] . "-" . $_->[0], [ "", "l" . $fix . "l-" . $_->[0] x 2 ],
1464             "l" . $fix . "-al-" . $_->[0] x 2, [ "", "l" . $fix . "l-" . $_->[0] x 2 ],
1465              
1466 0 0         } @moony, grep { $_->[0] ne "l" } @sunny
    0          
1467              
1468             } "", "a", "u", "i", $option{'non-quoting'} ? () : ( "\"", "\"a", "\"u", "\"i" )
1469             ),
1470              
1471             # initial vowels
1472              
1473             ( $option{'non-quoting'} ? () : (
1474              
1475             "\"", "\x{0671}", # this grapheme is mode-dependent in the next level
1476              
1477             ) ),
1478              
1479             (
1480             map {
1481              
1482 0 0         my $fix = $_;
    0          
1483              
1484 0 0         $_->[0] . "a", $_->[1] . "\x{064E}",
1485             $_->[0] . "u", $_->[1] . "\x{064F}",
1486             $_->[0] . "i", $_->[1] . "\x{0650}",
1487              
1488             ( $option{'non-refined'} ? () : (
1489              
1490             $_->[0] . "_a", $_->[1] . "\x{0670}",
1491             $_->[0] . "_u", $_->[1] . "\x{0657}",
1492             $_->[0] . "_i", $_->[1] . "\x{0656}",
1493              
1494             $_->[0] . "_aA", $_->[1] . "\x{0670}\x{0627}",
1495             $_->[0] . "_aY", $_->[1] . "\x{0670}\x{0649}",
1496             $_->[0] . "_aU", $_->[1] . "\x{0670}\x{0648}",
1497             $_->[0] . "_aI", $_->[1] . "\x{0670}\x{064A}",
1498              
1499             ) ),
1500              
1501             $_->[0] . "A", $_->[1] . "\x{064E}\x{0627}",
1502             $_->[0] . "Y", $_->[1] . "\x{064E}\x{0649}",
1503              
1504             $_->[0] . "_I", $_->[1] . "\x{0650}\x{0627}",
1505              
1506             $_->[0] . "U", $_->[1] . "\x{064F}\x{0648}",
1507             $_->[0] . "I", $_->[1] . "\x{0650}\x{064A}",
1508              
1509             $_->[0] . "Uw", [ $_->[1] . "\x{064F}\x{0648}\x{0651}", "|" ],
1510             $_->[0] . "Iy", [ $_->[1] . "\x{0650}\x{064A}\x{0651}", "|" ],
1511              
1512             ( $option{'non-refined'} ? () : (
1513              
1514             $_->[0] . "^A", "\x{0622}", # use no equivs
1515             $_->[0] . "^U", "\x{0623}\x{064F}\x{0648}", # use no equivs
1516             $_->[0] . "^I", "\x{0625}\x{0650}\x{064A}", # use no equivs
1517              
1518             ) ),
1519              
1520             $_->[0] . "aa", [ "", $_->[0] . "A" ],
1521             $_->[0] . "uw", [ "", $_->[0] . "U" ],
1522             $_->[0] . "iy", [ "", $_->[0] . "I" ],
1523              
1524             ( $option{'non-quoting'} ? () : (
1525              
1526             $_->[0] . "\"a", $_->[1] . "\"\x{064E}",
1527             $_->[0] . "\"u", $_->[1] . "\"\x{064F}",
1528             $_->[0] . "\"i", $_->[1] . "\"\x{0650}",
1529              
1530             ( $option{'non-refined'} ? () : (
1531              
1532             $_->[0] . "\"_a", $_->[1] . "\"\x{0670}",
1533             $_->[0] . "\"_u", $_->[1] . "\"\x{0657}",
1534             $_->[0] . "\"_i", $_->[1] . "\"\x{0656}",
1535              
1536             $_->[0] . "\"_aA", $_->[1] . "\"\x{0670}\x{0627}",
1537             $_->[0] . "\"_aY", $_->[1] . "\"\x{0670}\x{0649}",
1538             $_->[0] . "\"_aU", $_->[1] . "\"\x{0670}\x{0648}",
1539             $_->[0] . "\"_aI", $_->[1] . "\"\x{0670}\x{064A}",
1540              
1541             ) ),
1542              
1543             $_->[0] . "\"A", $_->[1] . "\"\x{064E}\x{0627}",
1544             $_->[0] . "\"Y", $_->[1] . "\"\x{064E}\x{0649}",
1545              
1546             $_->[0] . "\"A\"", $_->[1] . "\"\x{064E}\x{0627}\"\x{0652}",
1547             $_->[0] . "\"Y\"", $_->[1] . "\"\x{064E}\x{0649}\"\x{0652}",
1548              
1549             $_->[0] . "A\"", $_->[1] . "\x{064E}\x{0627}\"\x{0652}",
1550             $_->[0] . "Y\"", $_->[1] . "\x{064E}\x{0649}\"\x{0652}",
1551              
1552             $_->[0] . "\"_I", $_->[1] . "\"\x{0650}\x{0627}",
1553             $_->[0] . "\"_I\"", $_->[1] . "\"\x{0650}\x{0627}\"\x{0652}",
1554             $_->[0] . "_I\"", $_->[1] . "\x{0650}\x{0627}\"\x{0652}",
1555              
1556             $_->[0] . "\"U", $_->[1] . "\"\x{064F}\x{0648}",
1557             $_->[0] . "\"I", $_->[1] . "\"\x{0650}\x{064A}",
1558              
1559             $_->[0] . "\"U\"", $_->[1] . "\"\x{064F}\x{0648}\"\x{0652}",
1560             $_->[0] . "\"I\"", $_->[1] . "\"\x{0650}\x{064A}\"\x{0652}",
1561              
1562             $_->[0] . "U\"", $_->[1] . "\x{064F}\x{0648}\"\x{0652}",
1563             $_->[0] . "I\"", $_->[1] . "\x{0650}\x{064A}\"\x{0652}",
1564              
1565             $_->[0] . "\"Uw", [ $_->[1] . "\"\x{064F}\x{0648}\x{0651}", "|" ],
1566             $_->[0] . "\"Iy", [ $_->[1] . "\"\x{0650}\x{064A}\x{0651}", "|" ],
1567              
1568             ( $option{'non-refined'} ? () : (
1569              
1570             $_->[0] . "\"^A", "\"\x{0622}", # use no equivs
1571             $_->[0] . "\"^U", "\"\x{0623}\x{064F}\x{0648}", # use no equivs
1572             $_->[0] . "\"^I", "\"\x{0625}\x{0650}\x{064A}", # use no equivs
1573              
1574             ) ),
1575              
1576             $_->[0] . "\"aa", [ "", $_->[0] . "\"A" ],
1577             $_->[0] . "\"uw", [ "", $_->[0] . "\"U" ],
1578             $_->[0] . "\"iy", [ "", $_->[0] . "\"I" ],
1579              
1580             ) ),
1581              
1582             (
1583             map {
1584              
1585 0 0         $fix->[0] . "uw" . $_, [ $fix->[1] . "\x{064F}", "w" . $_ ],
    0          
    0          
    0          
    0          
    0          
    0          
1586             $fix->[0] . "iy" . $_, [ $fix->[1] . "\x{0650}", "y" . $_ ],
1587              
1588             ( $option{'non-quoting'} ? () : (
1589              
1590             $fix->[0] . "\"uw" . $_, [ $fix->[1] . "\"\x{064F}", "w" . $_ ],
1591             $fix->[0] . "\"iy" . $_, [ $fix->[1] . "\"\x{0650}", "y" . $_ ],
1592              
1593             ) ),
1594              
1595             } "\"", qw "a u i A Y U I _I", $option{'non-refined'} ? () : qw "_a _u _i ^A ^U ^I"
1596             ),
1597              
1598             $_->[0] . "_aA'|aN", $_->[1] . "\x{0670}\x{0627}\x{0621}\x{064B}",
1599             $_->[0] . "A'|aN", $_->[1] . "\x{064E}\x{0627}\x{0621}\x{064B}",
1600              
1601             $_->[0] . "aN", $_->[1] . "\x{064B}",
1602             $_->[0] . "uN", $_->[1] . "\x{064C}",
1603             $_->[0] . "iN", $_->[1] . "\x{064D}",
1604              
1605             ( $option{'non-quoting'} ? () : (
1606              
1607             $_->[0] . "\"_aA'|aN", $_->[1] . "\"\x{0670}\x{0627}\x{0621}\x{064B}",
1608             $_->[0] . "\"A'|aN", $_->[1] . "\"\x{064E}\x{0627}\x{0621}\x{064B}",
1609              
1610             $_->[0] . "\"_aA'|\"aN", $_->[1] . "\"\x{0670}\x{0627}\x{0621}\"\x{064B}",
1611             $_->[0] . "\"A'|\"aN", $_->[1] . "\"\x{064E}\x{0627}\x{0621}\"\x{064B}",
1612              
1613             $_->[0] . "_aA'|\"aN", $_->[1] . "\x{0670}\x{0627}\x{0621}\"\x{064B}",
1614             $_->[0] . "A'|\"aN", $_->[1] . "\x{064E}\x{0627}\x{0621}\"\x{064B}",
1615              
1616             $_->[0] . "\"A\"'|aN", $_->[1] . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\x{064B}",
1617             $_->[0] . "\"A\"'|\"aN", $_->[1] . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}",
1618             $_->[0] . "A\"'|\"aN", $_->[1] . "\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}",
1619              
1620             $_->[0] . "\"aN", $_->[1] . "\"\x{064B}",
1621             $_->[0] . "\"uN", $_->[1] . "\"\x{064C}",
1622             $_->[0] . "\"iN", $_->[1] . "\"\x{064D}",
1623              
1624             ) ),
1625              
1626             } $empty[1]
1627             ),
1628              
1629             # non-notation insertion escapes provided through ':xml'
1630              
1631             );
1632              
1633              
1634 5     5   75 no strict 'refs';
  5         93  
  5         7530  
1635              
1636 0           ${ $cls . '::decoder' } = $decoder;
  0            
1637              
1638 0 0         if ($option{'describe'}) {
1639              
1640 0           $_->describe('') foreach @{${ $cls . '::decoder' }};
  0            
  0            
1641             }
1642              
1643 0 0         $cls->demode(defined ${ $cls . '::demode' } ? ${ $cls . '::demode' } : 'default');
  0            
  0            
1644              
1645 0           return ${ $cls . '::decoder' };
  0            
1646             }
1647              
1648              
1649             sub eecoder ($@) {
1650 0     0 0   my $cls = shift @_;
1651 0           my $ext = shift @_;
1652              
1653 0 0         my %opt = @_ ? do { my $i = 0; map { ++$i % 2 ? lc $_ : $_ } @_ } : ();
  0 0          
  0            
  0            
1654              
1655 5     5   43 no strict 'refs';
  5         53  
  5         251  
1656              
1657 0           my $refcoder = \${ $cls . '::' . $ext };
  0            
1658              
1659 5     5   29 use strict 'refs';
  5         9  
  5         4953  
1660              
1661              
1662 0 0         if (exists $opt{'load'}) {
1663              
1664 0 0         if (ref \$opt{'load'} eq 'SCALAR') {
    0          
    0          
1665              
1666 0 0         if (my $done = do $opt{'load'}) { # file-define
1667              
1668 0           return ${$refcoder} = $done;
  0            
1669             }
1670             else {
1671              
1672 0 0         carp "Cannot parse " . $opt{'load'} . ": $@" if $@;
1673 0 0         carp "Cannot do " . $opt{'load'} . ": $!" unless defined $done;
1674 0           carp "Cannot run " . $opt{'load'};
1675              
1676 0           return undef;
1677             }
1678             }
1679             elsif (UNIVERSAL::isa($opt{'load'}, 'CODE')) {
1680              
1681 0           return ${$refcoder} = $opt{'load'}->();
  0            
1682             }
1683             elsif (UNIVERSAL::isa($opt{'load'}, 'ARRAY')) {
1684              
1685 0 0         if (grep { not $_->isa('Encode::Mapper') } @{$opt{'load'}}) {
  0            
  0            
1686 0           carp "Expecting a reference to an array of 'Encode::Mapper' objects";
1687 0           return undef;
1688             }
1689              
1690 0           return ${$refcoder} = $opt{'load'};
  0            
1691             }
1692              
1693 0           carp "Invalid type of the 'load' parameter, action ignored";
1694 0           return undef;
1695             }
1696              
1697 0 0         if (exists $opt{'dump'}) {
1698              
1699 0           require Data::Dumper;
1700              
1701 0           my ($data, $i, @refs, @data);
1702              
1703 0           $data = Data::Dumper->new([${$refcoder}], [$ext]);
  0            
1704              
1705 0           for ($i = 0; $i < @{${$refcoder}}; $i++) {
  0            
  0            
1706              
1707 0           $refs[$i] = ['L', 'H', $ext . "->[$i]" ];
1708 0           $data[$i] = ${$refcoder}->[$i]->dumper($refs[$i]);
  0            
1709             }
1710              
1711 0 0         if (ref \$opt{'dump'} eq 'SCALAR') {
    0          
1712              
1713 0 0 0       if ($opt{'dump'} =~ /^[A-Z][A-Za-z]*(\:\:[A-Z][A-Za-z]*)+$/) {
    0          
1714              
1715 0           my $class = $cls;
1716              
1717 0           for ($class, $opt{'dump'}) {
1718              
1719 0           $_ =~ s/\:\:/\//g;
1720 0           $_ .= '.pm';
1721             }
1722              
1723 0           my $where = $INC{$class} =~ /^(.*)$class$/;
1724              
1725 0           $opt{'dump'} = $where . $opt{'dump'};
1726             }
1727             elsif ($opt{'dump'} !~ s/^!// and -f $opt{'dump'}) { # 'SCALAR'
1728              
1729 0           carp "The file " . $opt{'dump'} . " exists, ignoring action";
1730 0           return undef;
1731             }
1732              
1733 0 0         open my $file, '>', $opt{'dump'} or die $opt{'dump'};
1734 0           print $file 'my ($L, $H, $' . $ext . ');';
1735              
1736 0           for ($i = 0; $i < @{${$refcoder}}; $i++) {
  0            
  0            
1737              
1738 0           print $file $data[$i]->Useqq(1)->Indent(0)->Dump();
1739             }
1740              
1741 0           print $file 'return $' . $ext . ';';
1742 0           close $file;
1743              
1744 0           return ${$refcoder};
  0            
1745             }
1746             elsif (UNIVERSAL::isa($opt{'dump'}, 'SCALAR')) {
1747              
1748 0           my $dump = ${$opt{'dump'}};
  0            
1749              
1750 0           ${$opt{'dump'}} = $data;
  0            
1751              
1752 0           return ${$refcoder};
  0            
1753             }
1754             }
1755              
1756 0           return -1;
1757             }
1758              
1759              
1760             sub enmode ($$) {
1761 0     0 1   my ($cls, $mode) = @_;
1762              
1763 0 0         $cls = blessed $cls if ref $cls;
1764              
1765 0 0         $mode = 'undef' unless defined $mode;
1766 0 0         $mode = $modemap{$mode} if exists $modemap{$mode};
1767              
1768 5     5   31 no strict 'refs';
  5         22  
  5         1465  
1769              
1770 0           my $return = ${ $cls . '::enmode' };
  0            
1771              
1772 0 0         ${ $cls . '::enmode' } = $mode if defined $mode;
  0            
1773              
1774 0 0         return $return unless defined ${ $cls . '::encoder' };
  0            
1775              
1776 0 0         if (defined $mode) {
1777              
1778 0 0 0       $cls->enmoder($mode) unless defined ${ $cls . '::encoder' }->[$mode + $enlevel] or $mode == 0;
  0            
1779              
1780 0           ${ $cls . '::encoder' }->[$enlevel - 1] = ${ $cls . '::encoder' }->[$mode + $enlevel];
  0            
  0            
1781             }
1782              
1783 0           return $return;
1784             }
1785              
1786              
1787             sub demode ($$) {
1788 0     0 1   my ($cls, $mode) = @_;
1789              
1790 0 0         $cls = blessed $cls if ref $cls;
1791              
1792 0 0         $mode = 'undef' unless defined $mode;
1793 0 0         $mode = $modemap{$mode} if exists $modemap{$mode};
1794              
1795 5     5   28 no strict 'refs';
  5         33  
  5         1004  
1796              
1797 0           my $return = ${ $cls . '::demode' };
  0            
1798              
1799 0 0         ${ $cls . '::demode' } = $mode if defined $mode;
  0            
1800              
1801 0 0         return $return unless defined ${ $cls . '::decoder' };
  0            
1802              
1803 0 0         if (defined $mode) {
1804              
1805 0 0 0       $cls->demoder($mode) unless defined ${ $cls . '::decoder' }->[$mode + $delevel] or $mode == 0;
  0            
1806              
1807 0           ${ $cls . '::decoder' }->[$delevel - 1] = ${ $cls . '::decoder' }->[$mode + $delevel];
  0            
  0            
1808             }
1809              
1810 0           return $return;
1811             }
1812              
1813              
1814             sub enmoder ($$@) {
1815 0     0 0   my ($cls, $mode) = @_;
1816              
1817 5     5   29 no strict 'refs';
  5         20  
  5         28289  
1818              
1819 0           return ${ $cls . '::encoder' }->[$mode + $enlevel] = undef;
  0            
1820             }
1821              
1822              
1823             sub demoder ($$@) {
1824 0     0 0   my ($cls, $mode) = @_;
1825              
1826 0           my $demoder = [];
1827              
1828              
1829             # rules for the fullvocalize mode
1830              
1831 0           $demoder->[4] = [
1832              
1833             [
1834             'silent' => 0,
1835             ],
1836              
1837             "\x{0671}", "\x{0627}",
1838              
1839             "\"\x{0652}", "",
1840             "\"\x{064E}", "",
1841             "\"\x{064F}", "",
1842             "\"\x{0650}", "",
1843             "\"\x{064B}", "",
1844             "\"\x{064C}", "",
1845             "\"\x{064D}", "",
1846             "\"\x{0670}", "",
1847             "\"\x{0657}", "",
1848             "\"\x{0656}", "",
1849              
1850             "\"", "",
1851              
1852             "\x{064E}\x{0627}\"\x{0652}", "\x{064E}\x{0627}\x{0652}",
1853             "\"\x{064E}\x{0627}\"\x{0652}", "\x{0627}\x{0652}",
1854              
1855             (
1856             ( $option{'font-fixing'} ? (
1857              
1858             map {
1859              
1860 0           "\x{0644}" . $_ . "\x{064E}\x{0627}\"\x{0652}", "\x{0644}\x{0627}" . $_ . "\x{064E}\x{0652}",
1861             "\x{0644}" . $_ . "\"\x{064E}\x{0627}\"\x{0652}", "\x{0644}\x{0627}" . $_ . "\x{0652}",
1862              
1863             } "", "\x{0651}"
1864              
1865             ) : () ),
1866             ),
1867              
1868             "\x{064E}\x{0649}\"\x{0652}", "\x{064E}\x{0649}\x{0652}",
1869             "\"\x{064E}\x{0649}\"\x{0652}", "\x{0649}\x{0652}",
1870              
1871             "\x{064F}\x{0648}\"\x{0652}", "\x{064F}\x{0648}\x{0652}",
1872             "\"\x{064F}\x{0648}\"\x{0652}", "\x{0648}\x{0652}",
1873              
1874             "\x{0650}\x{064A}\"\x{0652}", "\x{0650}\x{064A}\x{0652}",
1875             "\"\x{0650}\x{064A}\"\x{0652}", "\x{064A}\x{0652}",
1876              
1877             # modern external/internal substitution with wa.sla
1878             (
1879             map {
1880              
1881 0           my $vowel = $_;
1882              
1883 0           map {
1884              
1885 0           "\x{064E}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}" . $_ . "\x{0671}", "\"" . $vowel ],
1886             "\x{064F}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}" . $_ . "\x{0671}", "\"" . $vowel ],
1887             "\x{0650}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}" . $_ . "\x{0671}", "\"" . $vowel ],
1888              
1889             "\x{064E}\x{0627}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0627}" . $_ . "\x{0671}", "\"" . $vowel ],
1890             "\x{064E}\x{0649}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0649}" . $_ . "\x{0671}", "\"" . $vowel ],
1891             "\x{064F}\x{0648}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}\x{0648}" . $_ . "\x{0671}", "\"" . $vowel ],
1892             "\x{0650}\x{064A}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}\x{064A}" . $_ . "\x{0671}", "\"" . $vowel ],
1893              
1894             # quoted
1895              
1896             "\"\x{064E}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0671}", "\"" . $vowel ],
1897             "\"\x{064F}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0671}", "\"" . $vowel ],
1898             "\"\x{0650}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0671}", "\"" . $vowel ],
1899              
1900             "\"\x{064E}\x{0627}" . $_ . "\x{0627}" . $vowel, [ "\x{0627}" . $_ . "\x{0671}", "\"" . $vowel ],
1901             "\"\x{064E}\x{0649}" . $_ . "\x{0627}" . $vowel, [ "\x{0649}" . $_ . "\x{0671}", "\"" . $vowel ],
1902             "\"\x{064F}\x{0648}" . $_ . "\x{0627}" . $vowel, [ "\x{0648}" . $_ . "\x{0671}", "\"" . $vowel ],
1903             "\"\x{0650}\x{064A}" . $_ . "\x{0627}" . $vowel, [ "\x{064A}" . $_ . "\x{0671}", "\"" . $vowel ],
1904              
1905             "\"\x{064E}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ],
1906             "\"\x{064F}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ],
1907             "\"\x{0650}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ],
1908              
1909             "\"\x{064E}\x{0627}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0627}" . $_ . "\x{0627}", $vowel ],
1910             "\"\x{064E}\x{0649}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0649}" . $_ . "\x{0627}", $vowel ],
1911             "\"\x{064F}\x{0648}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0648}" . $_ . "\x{0627}", $vowel ],
1912             "\"\x{0650}\x{064A}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064A}" . $_ . "\x{0627}", $vowel ],
1913              
1914             "\x{064E}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}" . $_ . "\x{0627}", $vowel ],
1915             "\x{064F}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064F}" . $_ . "\x{0627}", $vowel ],
1916             "\x{0650}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0650}" . $_ . "\x{0627}", $vowel ],
1917              
1918             "\x{064E}\x{0627}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}\x{0627}" . $_ . "\x{0627}", $vowel ],
1919             "\x{064E}\x{0649}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}\x{0649}" . $_ . "\x{0627}", $vowel ],
1920             "\x{064F}\x{0648}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064F}\x{0648}" . $_ . "\x{0627}", $vowel ],
1921             "\x{0650}\x{064A}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0650}\x{064A}" . $_ . "\x{0627}", $vowel ],
1922              
1923             } "", "\x09", "\x0A", "\x0D", "\x20", "\x0D\x0A", "\x20\x20", "\x20\x20\x20", "\x20\x20\x20\x20"
1924              
1925             } "\x{064E}", "\x{064F}", "\x{0650}"
1926             ),
1927              
1928             # laam + 'alif .. either enforce ligatures, or shuffle the diacritics
1929             (
1930             ( $option{'font-fixing'} ? (
1931              
1932             map {
1933              
1934 0           my $alif = $_;
1935              
1936 0           map {
1937              
1938 0           my $vowel = $_;
1939              
1940 0           map {
1941              
1942 0           "\x{0644}" . $_ . $vowel . $alif, "\x{0644}" . $alif . $_ . $vowel,
1943             "\x{0644}" . $_ . "\"" . $vowel . $alif, "\x{0644}" . $alif . $_,
1944              
1945             } "", "\x{0651}"
1946              
1947             } "\x{064E}", "\x{064F}", "\x{0650}",
1948             "\x{064B}", "\x{064C}", "\x{064D}",
1949             "\x{0652}"
1950              
1951             } "\x{0622}", "\x{0623}", "\x{0625}", "\x{0627}" #, "\x{0671}"
1952              
1953             ) : () ),
1954             ),
1955              
1956             (
1957             ( $option{'font-fixing'} ? (
1958              
1959             map {
1960              
1961 0           my $vowel = $_;
1962              
1963 0           map {
1964              
1965 0           "\x{0644}" . $_ . $vowel . "\x{0671}", "\x{0644}\x{0627}" . $_ . $vowel,
1966             "\x{0644}" . $_ . "\"" . $vowel . "\x{0671}", "\x{0644}\x{0627}" . $_,
1967              
1968             } "", "\x{0651}"
1969              
1970             } "\x{064E}", "\x{064F}", "\x{0650}",
1971             "\x{064B}", "\x{064C}", "\x{064D}",
1972             "\x{0652}"
1973              
1974             ) : () ),
1975             ),
1976              
1977             # laam + vowel + 'alif + vowel .. internal substitution with wa.sla
1978             (
1979             ( $option{'font-fixing'} ? (
1980              
1981             map {
1982              
1983 0 0         my $double = $_;
    0          
    0          
    0          
1984              
1985 0           map {
1986              
1987 0           my $vowel = $_;
1988              
1989 0           map {
1990              
1991 0           "\x{0644}" . $double . $vowel . "\x{0627}" . $_, [ "\x{0644}\x{0671}" . $double . $vowel, "\"" . $_ ],
1992              
1993             # quoted
1994              
1995             "\x{0644}" . $double . "\"" . $vowel . "\x{0627}" . $_, [ "\x{0644}\x{0671}" . $double, "\"" . $_ ],
1996             "\x{0644}" . $double . "\"" . $vowel . "\x{0627}\"" . $_, [ "\x{0644}\x{0627}" . $double, $_ ],
1997             "\x{0644}" . $double . $vowel . "\x{0627}\"" . $_, [ "\x{0644}\x{0627}" . $double . $vowel, $_ ],
1998              
1999             } "\x{064E}", "\x{064F}", "\x{0650}"
2000              
2001             } "\x{064E}", "\x{064F}", "\x{0650}"
2002              
2003             } "", "\x{0651}"
2004              
2005             ) : () ),
2006             ),
2007              
2008             # optional ligatures to enforce here
2009              
2010             ];
2011              
2012              
2013             # rules for the vocalize mode
2014              
2015 0           $demoder->[3] = [
2016              
2017             [
2018             'silent' => 0,
2019             ],
2020              
2021             "\"\x{0652}", "\x{0652}",
2022             "\"\x{064E}", "",
2023             "\"\x{064F}", "",
2024             "\"\x{0650}", "",
2025             "\"\x{064B}", "",
2026             "\"\x{064C}", "",
2027             "\"\x{064D}", "",
2028             "\"\x{0670}", "",
2029             "\"\x{0657}", "",
2030             "\"\x{0656}", "",
2031              
2032             "\x{0652}", "",
2033              
2034             "\"", "",
2035              
2036             # modern external/internal substitution with wa.sla
2037             (
2038             map {
2039              
2040 0           my $vowel = $_;
2041              
2042 0           map {
2043              
2044 0           "\x{064E}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}" . $_ . "\x{0627}", "\"" . $vowel ],
2045             "\x{064F}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}" . $_ . "\x{0627}", "\"" . $vowel ],
2046             "\x{0650}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}" . $_ . "\x{0627}", "\"" . $vowel ],
2047              
2048             "\x{064E}\x{0627}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0627}" . $_ . "\x{0627}", "\"" . $vowel ],
2049             "\x{064E}\x{0649}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0649}" . $_ . "\x{0627}", "\"" . $vowel ],
2050             "\x{064F}\x{0648}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}\x{0648}" . $_ . "\x{0627}", "\"" . $vowel ],
2051             "\x{0650}\x{064A}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}\x{064A}" . $_ . "\x{0627}", "\"" . $vowel ],
2052              
2053             # quoted
2054              
2055             "\"\x{064E}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0627}", "\"" . $vowel ],
2056             "\"\x{064F}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0627}", "\"" . $vowel ],
2057             "\"\x{0650}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0627}", "\"" . $vowel ],
2058              
2059             "\"\x{064E}\x{0627}" . $_ . "\x{0627}" . $vowel, [ "\x{0627}" . $_ . "\x{0627}", "\"" . $vowel ],
2060             "\"\x{064E}\x{0649}" . $_ . "\x{0627}" . $vowel, [ "\x{0649}" . $_ . "\x{0627}", "\"" . $vowel ],
2061             "\"\x{064F}\x{0648}" . $_ . "\x{0627}" . $vowel, [ "\x{0648}" . $_ . "\x{0627}", "\"" . $vowel ],
2062             "\"\x{0650}\x{064A}" . $_ . "\x{0627}" . $vowel, [ "\x{064A}" . $_ . "\x{0627}", "\"" . $vowel ],
2063              
2064             "\"\x{064E}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ],
2065             "\"\x{064F}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ],
2066             "\"\x{0650}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ],
2067              
2068             "\"\x{064E}\x{0627}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0627}" . $_ . "\x{0627}", $vowel ],
2069             "\"\x{064E}\x{0649}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0649}" . $_ . "\x{0627}", $vowel ],
2070             "\"\x{064F}\x{0648}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0648}" . $_ . "\x{0627}", $vowel ],
2071             "\"\x{0650}\x{064A}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064A}" . $_ . "\x{0627}", $vowel ],
2072              
2073             "\x{064E}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}" . $_ . "\x{0627}", $vowel ],
2074             "\x{064F}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064F}" . $_ . "\x{0627}", $vowel ],
2075             "\x{0650}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0650}" . $_ . "\x{0627}", $vowel ],
2076              
2077             "\x{064E}\x{0627}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}\x{0627}" . $_ . "\x{0627}", $vowel ],
2078             "\x{064E}\x{0649}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}\x{0649}" . $_ . "\x{0627}", $vowel ],
2079             "\x{064F}\x{0648}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064F}\x{0648}" . $_ . "\x{0627}", $vowel ],
2080             "\x{0650}\x{064A}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0650}\x{064A}" . $_ . "\x{0627}", $vowel ],
2081              
2082             } "", "\x09", "\x0A", "\x0D", "\x20", "\x0D\x0A", "\x20\x20", "\x20\x20\x20", "\x20\x20\x20\x20"
2083              
2084             } "\x{064E}", "\x{064F}", "\x{0650}"
2085             ),
2086              
2087             # laam + 'alif .. either enforce ligatures, or shuffle the diacritics
2088             (
2089             ( $option{'font-fixing'} ? (
2090              
2091             map {
2092              
2093 0           my $alif = $_;
2094              
2095 0           map {
2096              
2097 0           my $vowel = $_;
2098              
2099 0           map {
2100              
2101 0           "\x{0644}" . $_ . $vowel . $alif, "\x{0644}" . $alif . $_ . $vowel,
2102             "\x{0644}" . $_ . "\"" . $vowel . $alif, "\x{0644}" . $alif . $_,
2103              
2104             } "", "\x{0651}"
2105              
2106             } "\x{064E}", "\x{064F}", "\x{0650}",
2107             "\x{064B}", "\x{064C}", "\x{064D}",
2108             # "\x{0652}"
2109              
2110             } "\x{0622}", "\x{0623}", "\x{0625}", "\x{0627}", "\x{0671}"
2111              
2112             ) : () ),
2113             ),
2114              
2115             (
2116             ( $option{'font-fixing'} ? (
2117              
2118             map {
2119              
2120 0           my $alif = $_;
2121              
2122 0           map {
2123              
2124 0           "\x{0644}" . $_ . "\x{0652}" . $alif, "\x{0644}" . $alif . $_,
2125             "\x{0644}" . $_ . "\"\x{0652}" . $alif, "\x{0644}" . $alif . $_ . "\x{0652}",
2126              
2127             } "", "\x{0651}"
2128              
2129             } "\x{0622}", "\x{0623}", "\x{0625}", "\x{0627}", "\x{0671}"
2130              
2131             ) : () ),
2132             ),
2133              
2134             # laam + vowel + 'alif + vowel .. internal substitution with wa.sla
2135             (
2136             ( $option{'font-fixing'} ? (
2137              
2138             map {
2139              
2140 0 0         my $double = $_;
    0          
    0          
2141              
2142 0           map {
2143              
2144 0           my $vowel = $_;
2145              
2146 0           map {
2147              
2148 0           "\x{0644}" . $double . $vowel . "\x{0627}" . $_, [ "\x{0644}\x{0627}" . $double . $vowel, "\"" . $_ ],
2149              
2150             # quoted
2151              
2152             "\x{0644}" . $double . "\"" . $vowel . "\x{0627}" . $_, [ "\x{0644}\x{0627}" . $double, "\"" . $_ ],
2153             "\x{0644}" . $double . "\"" . $vowel . "\x{0627}\"" . $_, [ "\x{0644}\x{0627}" . $double, $_ ],
2154             "\x{0644}" . $double . $vowel . "\x{0627}\"" . $_, [ "\x{0644}\x{0627}" . $double . $vowel, $_ ],
2155              
2156             } "\x{064E}", "\x{064F}", "\x{0650}"
2157              
2158             } "\x{064E}", "\x{064F}", "\x{0650}"
2159              
2160             } "", "\x{0651}"
2161              
2162             ) : () ),
2163             ),
2164              
2165             # optional ligatures to enforce here
2166              
2167             ];
2168              
2169              
2170             # rules for the novocalize mode
2171              
2172 0           $demoder->[2] = [
2173              
2174             [
2175             'silent' => 0,
2176             ],
2177              
2178             "\"\x{0652}", "\x{0652}",
2179             "\"\x{064E}", "\x{064E}",
2180             "\"\x{064F}", "\x{064F}",
2181             "\"\x{0650}", "\x{0650}",
2182             "\"\x{064B}", "\x{064B}",
2183             "\"\x{064C}", "\x{064C}",
2184             "\"\x{064D}", "\x{064D}",
2185             "\"\x{0670}", "\x{0670}",
2186             "\"\x{0657}", "\x{0657}",
2187             "\"\x{0656}", "\x{0656}",
2188              
2189             "\x{0652}", "",
2190             "\x{064E}", "",
2191             "\x{064F}", "",
2192             "\x{0650}", "",
2193             "\x{064B}", "",
2194             "\x{064C}", "",
2195             "\x{064D}", "",
2196             "\x{0670}", "",
2197             "\x{0657}", "",
2198             "\x{0656}", "",
2199              
2200             "\"", "",
2201              
2202             # modern internal substitution with "fictitious" wa.sla .. lam + vowel + 'alif + vowel below
2203              
2204             # modern external substitution with "fictitious" wa.sla
2205              
2206             # laam + 'alif .. either enforce ligatures, or shuffle the diacritics
2207             (
2208             ( $option{'font-fixing'} ? (
2209              
2210             map {
2211              
2212 0 0         my $alif = $_;
2213              
2214 0           map {
2215              
2216 0           my $vowel = $_;
2217              
2218 0           map {
2219              
2220 0           "\x{0644}" . $_ . $vowel . $alif, "\x{0644}" . $alif . $_,
2221             "\x{0644}" . $_ . "\"" . $vowel . $alif, "\x{0644}" . $alif . $_ . $vowel,
2222              
2223             } "", "\x{0651}"
2224              
2225             } "\x{064E}", "\x{064F}", "\x{0650}",
2226             "\x{064B}", "\x{064C}", "\x{064D}",
2227             "\x{0652}"
2228              
2229             } "\x{0622}", "\x{0623}", "\x{0625}", "\x{0627}", "\x{0671}"
2230              
2231             ) : () ),
2232             ),
2233              
2234             # laam + vowel + 'alif + vowel .. internal substitution with wa.sla
2235              
2236             # optional ligatures to enforce here
2237              
2238             ];
2239              
2240              
2241             # rules for the noshadda mode
2242              
2243 0           $demoder->[1] = [
2244              
2245             [
2246             'silent' => 0,
2247             ],
2248              
2249             ];
2250              
2251              
2252             # original no-quotes rules
2253              
2254 0           $demoder->[0] = [
2255              
2256             [
2257             'silent' => 0,
2258             ],
2259              
2260             # modern internal substitution with wa.sla .. lam + vowel + 'alif + vowel below
2261             (
2262             map {
2263              
2264 0           my $vowel = $_;
2265              
2266 0           map {
2267              
2268 0           $vowel . "\x{0627}" . $_, $vowel . "\x{0671}",
2269              
2270             } "\x{064E}", "\x{064F}", "\x{0650}"
2271              
2272             } "\x{064E}", "\x{064F}", "\x{0650}"
2273             ),
2274              
2275             # modern external substitution with wa.sla
2276             (
2277             map {
2278              
2279 0           my $vowel = $_;
2280              
2281 0           map {
2282              
2283 0           "\x{064E}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}" . $_, "\x{0671}" ],
2284             "\x{064F}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}" . $_, "\x{0671}" ],
2285             "\x{0650}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}" . $_, "\x{0671}" ],
2286              
2287             "\x{064E}\x{0627}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0627}" . $_, "\x{0671}" ],
2288             "\x{064E}\x{0649}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0649}" . $_, "\x{0671}" ],
2289             "\x{064F}\x{0648}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}\x{0648}" . $_, "\x{0671}" ],
2290             "\x{0650}\x{064A}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}\x{064A}" . $_, "\x{0671}" ],
2291              
2292             } "\x09", "\x0A", "\x0D", "\x20", "\x0D\x0A", "\x20\x20", "\x20\x20\x20", "\x20\x20\x20\x20"
2293              
2294             } "\x{064E}", "\x{064F}", "\x{0650}"
2295             ),
2296              
2297             # laam + 'alif .. either enforce ligatures, or shuffle the diacritics
2298             (
2299             ( $option{'font-fixing'} ? (
2300              
2301             map {
2302              
2303 0           my $alif = $_;
2304              
2305 0           map {
2306              
2307 0           my $vowel = $_;
2308              
2309 0           map {
2310              
2311 0           "\x{0644}" . $_ . $vowel . $alif,
2312             "\x{0644}" . $alif . $_ . $vowel,
2313              
2314             } "", "\x{0651}"
2315              
2316             } "\x{064E}", "\x{064F}", "\x{0650}",
2317             "\x{064B}", "\x{064C}", "\x{064D}",
2318             "\x{0652}"
2319              
2320             } "\x{0622}", "\x{0623}", "\x{0625}", "\x{0627}", "\x{0671}"
2321              
2322             ) : () ),
2323             ),
2324              
2325             # laam + vowel + 'alif + vowel .. internal substitution with wa.sla
2326             (
2327             ( $option{'font-fixing'} ? (
2328              
2329             map {
2330              
2331 0 0         my $double = $_;
    0          
2332              
2333 0           map {
2334              
2335 0           my $vowel = $_;
2336              
2337 0           map {
2338              
2339 0           "\x{0644}" . $double . $vowel . "\x{0627}" . $_,
2340             "\x{0644}" . "\x{0671}" . $double . $vowel,
2341              
2342             } "\x{064E}", "\x{064F}", "\x{0650}"
2343              
2344             } "\x{064E}", "\x{064F}", "\x{0650}"
2345              
2346             } "", "\x{0651}"
2347              
2348             ) : () ),
2349             ),
2350              
2351             # optional ligatures to enforce here
2352              
2353             ];
2354              
2355              
2356 5     5   50 no strict 'refs';
  5         11  
  5         2203  
2357              
2358 0           ${ $cls . '::decoder' }->[$mode + $delevel] = Encode::Mapper->compile(@{$demoder->[$mode]});
  0            
  0            
2359              
2360 0 0         ${ $cls . '::decoder' }->[$mode + $delevel]->describe('') if $option{'describe'};
  0            
2361              
2362 0           return ${ $cls . '::decoder' }->[$mode + $delevel];
  0            
2363             }
2364              
2365              
2366             1;
2367              
2368             __END__