line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Lingua/Multinational/Translit/ICAO.pm |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# $Id: ICAO.pm 6 2009-09-16 15:37:46Z stro $ |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Copyright (c) 2007-2009 Serguei Trouchelle. All rights reserved. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it |
8
|
|
|
|
|
|
|
# under the same terms as Perl itself. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# History: |
11
|
|
|
|
|
|
|
# 1.05 2009/09/16 Changed 5.8.0 to 5.008 |
12
|
|
|
|
|
|
|
# 1.04 2007/07/07 use Encode in preference of Text::Iconv (thanks to Nikita Dedik) |
13
|
|
|
|
|
|
|
# Rate Text::Iconv Encode |
14
|
|
|
|
|
|
|
# Text::Iconv 13243/s -- -41% |
15
|
|
|
|
|
|
|
# Encode 22386/s 69% -- |
16
|
|
|
|
|
|
|
# 1.02 2007/07/05 use 5.8.0 added |
17
|
|
|
|
|
|
|
# 1.01 2007/07/04 Initial revision |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 NAME |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Lingua::Multinational::Translit::ICAO -- Multinational characters transliteration into ICAO Doc 9303 |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Lingua::Multinational::Translit::ICAO qw/ ml2icao /; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
print ml2icao('word', 'iso-8859-1'); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Lingua::Multinational::Translit::ICAO can be used for transliteration of multinational |
32
|
|
|
|
|
|
|
characters in conformance with ICAO Doc 9303 Recommendations. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 METHODS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
package Lingua::Multinational::Translit::ICAO; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
require Exporter; |
41
|
2
|
|
|
2
|
|
12760
|
use Config; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
83
|
|
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
50
|
|
44
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
61
|
|
45
|
2
|
|
|
2
|
|
32
|
use 5.008; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
69
|
|
46
|
2
|
|
|
2
|
|
824
|
use utf8; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
8
|
|
47
|
|
|
|
|
|
|
|
48
|
2
|
|
|
2
|
|
1813
|
use Encode; |
|
2
|
|
|
|
|
23783
|
|
|
2
|
|
|
|
|
851
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
our @EXPORT = qw/ /; |
51
|
|
|
|
|
|
|
our @EXPORT_OK = qw/ ml2icao /; |
52
|
|
|
|
|
|
|
our %EXPORT_TAGS = qw / /; |
53
|
|
|
|
|
|
|
our @ISA = qw/Exporter/; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
our $VERSION = '1.05'; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $table = q!1 1 |
58
|
|
|
|
|
|
|
Á A |
59
|
|
|
|
|
|
|
À A |
60
|
|
|
|
|
|
|
 A |
61
|
|
|
|
|
|
|
Ä AE |
62
|
|
|
|
|
|
|
à A |
63
|
|
|
|
|
|
|
Ă A |
64
|
|
|
|
|
|
|
Å AA |
65
|
|
|
|
|
|
|
Ā A |
66
|
|
|
|
|
|
|
Ą A |
67
|
|
|
|
|
|
|
á a |
68
|
|
|
|
|
|
|
à a |
69
|
|
|
|
|
|
|
â a |
70
|
|
|
|
|
|
|
ä ae |
71
|
|
|
|
|
|
|
ã a |
72
|
|
|
|
|
|
|
ă a |
73
|
|
|
|
|
|
|
å aa |
74
|
|
|
|
|
|
|
ā a |
75
|
|
|
|
|
|
|
ą a |
76
|
|
|
|
|
|
|
Ć C |
77
|
|
|
|
|
|
|
ć c |
78
|
|
|
|
|
|
|
Ĉ C |
79
|
|
|
|
|
|
|
ĉ c |
80
|
|
|
|
|
|
|
Č C |
81
|
|
|
|
|
|
|
č c |
82
|
|
|
|
|
|
|
Ċ C |
83
|
|
|
|
|
|
|
ċ c |
84
|
|
|
|
|
|
|
Ç C |
85
|
|
|
|
|
|
|
ç c |
86
|
|
|
|
|
|
|
Đ D |
87
|
|
|
|
|
|
|
đ d |
88
|
|
|
|
|
|
|
Ď D |
89
|
|
|
|
|
|
|
ď d |
90
|
|
|
|
|
|
|
É E |
91
|
|
|
|
|
|
|
È E |
92
|
|
|
|
|
|
|
Ê E |
93
|
|
|
|
|
|
|
Ë E |
94
|
|
|
|
|
|
|
é e |
95
|
|
|
|
|
|
|
è e |
96
|
|
|
|
|
|
|
ê e |
97
|
|
|
|
|
|
|
ë e |
98
|
|
|
|
|
|
|
Ě E |
99
|
|
|
|
|
|
|
ě e |
100
|
|
|
|
|
|
|
Ė E |
101
|
|
|
|
|
|
|
ė e |
102
|
|
|
|
|
|
|
Ē E |
103
|
|
|
|
|
|
|
ē e |
104
|
|
|
|
|
|
|
Ę E |
105
|
|
|
|
|
|
|
ę e |
106
|
|
|
|
|
|
|
Ĕ E |
107
|
|
|
|
|
|
|
ĕ e |
108
|
|
|
|
|
|
|
Ĝ G |
109
|
|
|
|
|
|
|
ĝ g |
110
|
|
|
|
|
|
|
Ğ G |
111
|
|
|
|
|
|
|
ğ g |
112
|
|
|
|
|
|
|
Ġ G |
113
|
|
|
|
|
|
|
ġ g |
114
|
|
|
|
|
|
|
Ģ G |
115
|
|
|
|
|
|
|
ģ g |
116
|
|
|
|
|
|
|
Ħ H |
117
|
|
|
|
|
|
|
ħ h |
118
|
|
|
|
|
|
|
Ĥ H |
119
|
|
|
|
|
|
|
ĥ h |
120
|
|
|
|
|
|
|
ı i |
121
|
|
|
|
|
|
|
Í I |
122
|
|
|
|
|
|
|
Ì I |
123
|
|
|
|
|
|
|
Î I |
124
|
|
|
|
|
|
|
Ï I |
125
|
|
|
|
|
|
|
İ I |
126
|
|
|
|
|
|
|
Ĩ I |
127
|
|
|
|
|
|
|
ĩ i |
128
|
|
|
|
|
|
|
Ī I |
129
|
|
|
|
|
|
|
ī i |
130
|
|
|
|
|
|
|
Ĭ I |
131
|
|
|
|
|
|
|
ĭ i |
132
|
|
|
|
|
|
|
Į I |
133
|
|
|
|
|
|
|
į i |
134
|
|
|
|
|
|
|
Ĵ J |
135
|
|
|
|
|
|
|
ĵ j |
136
|
|
|
|
|
|
|
Ķ K |
137
|
|
|
|
|
|
|
ķ k |
138
|
|
|
|
|
|
|
Ł L |
139
|
|
|
|
|
|
|
Ĺ L |
140
|
|
|
|
|
|
|
Ľ L |
141
|
|
|
|
|
|
|
Ļ L |
142
|
|
|
|
|
|
|
Ŀ L |
143
|
|
|
|
|
|
|
ł l |
144
|
|
|
|
|
|
|
ĺ l |
145
|
|
|
|
|
|
|
ľ l |
146
|
|
|
|
|
|
|
ļ l |
147
|
|
|
|
|
|
|
ŀ l |
148
|
|
|
|
|
|
|
Ń N |
149
|
|
|
|
|
|
|
Ň N |
150
|
|
|
|
|
|
|
Ņ N |
151
|
|
|
|
|
|
|
Ŋ N |
152
|
|
|
|
|
|
|
ń n |
153
|
|
|
|
|
|
|
ň n |
154
|
|
|
|
|
|
|
ņ n |
155
|
|
|
|
|
|
|
ŋ n |
156
|
|
|
|
|
|
|
ñ n |
157
|
|
|
|
|
|
|
Ñ N |
158
|
|
|
|
|
|
|
Ø OE |
159
|
|
|
|
|
|
|
Ó O |
160
|
|
|
|
|
|
|
Ò O |
161
|
|
|
|
|
|
|
Ô O |
162
|
|
|
|
|
|
|
Ö OE |
163
|
|
|
|
|
|
|
Õ O |
164
|
|
|
|
|
|
|
ó o |
165
|
|
|
|
|
|
|
ò o |
166
|
|
|
|
|
|
|
ô o |
167
|
|
|
|
|
|
|
õ o |
168
|
|
|
|
|
|
|
ö oe |
169
|
|
|
|
|
|
|
Ő O |
170
|
|
|
|
|
|
|
ő o |
171
|
|
|
|
|
|
|
Ō O |
172
|
|
|
|
|
|
|
ō o |
173
|
|
|
|
|
|
|
Ŏ O |
174
|
|
|
|
|
|
|
ŏ o |
175
|
|
|
|
|
|
|
Ŕ R |
176
|
|
|
|
|
|
|
ŕ r |
177
|
|
|
|
|
|
|
Ŗ R |
178
|
|
|
|
|
|
|
ŗ r |
179
|
|
|
|
|
|
|
Ř R |
180
|
|
|
|
|
|
|
ř r |
181
|
|
|
|
|
|
|
Ś S |
182
|
|
|
|
|
|
|
Ŝ S |
183
|
|
|
|
|
|
|
Ş S |
184
|
|
|
|
|
|
|
Š S |
185
|
|
|
|
|
|
|
ś s |
186
|
|
|
|
|
|
|
ŝ s |
187
|
|
|
|
|
|
|
ş s |
188
|
|
|
|
|
|
|
š s |
189
|
|
|
|
|
|
|
Ŧ T |
190
|
|
|
|
|
|
|
Ť T |
191
|
|
|
|
|
|
|
Ţ T |
192
|
|
|
|
|
|
|
ŧ t |
193
|
|
|
|
|
|
|
ť t |
194
|
|
|
|
|
|
|
ţ t |
195
|
|
|
|
|
|
|
Ú U |
196
|
|
|
|
|
|
|
Ù U |
197
|
|
|
|
|
|
|
Û U |
198
|
|
|
|
|
|
|
Ü UE |
199
|
|
|
|
|
|
|
ú u |
200
|
|
|
|
|
|
|
ù u |
201
|
|
|
|
|
|
|
û u |
202
|
|
|
|
|
|
|
ü ue |
203
|
|
|
|
|
|
|
Ũ U |
204
|
|
|
|
|
|
|
Ŭ U |
205
|
|
|
|
|
|
|
Ű U |
206
|
|
|
|
|
|
|
Ů U |
207
|
|
|
|
|
|
|
Ū U |
208
|
|
|
|
|
|
|
Ų U |
209
|
|
|
|
|
|
|
ũ u |
210
|
|
|
|
|
|
|
ŭ u |
211
|
|
|
|
|
|
|
ű u |
212
|
|
|
|
|
|
|
ů u |
213
|
|
|
|
|
|
|
ū u |
214
|
|
|
|
|
|
|
Ŵ W |
215
|
|
|
|
|
|
|
ŵ w |
216
|
|
|
|
|
|
|
Ŷ Y |
217
|
|
|
|
|
|
|
ŷ y |
218
|
|
|
|
|
|
|
Ź Z |
219
|
|
|
|
|
|
|
ź z |
220
|
|
|
|
|
|
|
Ž Z |
221
|
|
|
|
|
|
|
ž z |
222
|
|
|
|
|
|
|
Ż Z |
223
|
|
|
|
|
|
|
ż z |
224
|
|
|
|
|
|
|
Ý Y |
225
|
|
|
|
|
|
|
ý y |
226
|
|
|
|
|
|
|
Ÿ Y |
227
|
|
|
|
|
|
|
Þ TH |
228
|
|
|
|
|
|
|
Æ AE |
229
|
|
|
|
|
|
|
æ ae |
230
|
|
|
|
|
|
|
þ th |
231
|
|
|
|
|
|
|
IJ IJ |
232
|
|
|
|
|
|
|
ij ij |
233
|
|
|
|
|
|
|
Œ OE |
234
|
|
|
|
|
|
|
œ oe |
235
|
|
|
|
|
|
|
ß SS |
236
|
|
|
|
|
|
|
2 2!; |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
our %ml2icao = split /\s+/, $table; |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 ml2icao ( $string, [ $encoding ]) |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
This method converts $string from multinational character set to ICAO transliteration. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Optional $encoding parameter allows to specify $string's encoding (default is 'utf-8') |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=cut |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
sub ml2icao { |
249
|
5
|
|
|
5
|
1
|
20
|
my $val = shift; |
250
|
5
|
|
|
|
|
7
|
my $lang = shift; |
251
|
5
|
|
|
|
|
7
|
my $enc = shift; |
252
|
5
|
50
|
|
|
|
12
|
if ($enc) { |
253
|
0
|
|
|
|
|
0
|
$val = Encode::decode($enc, $val); |
254
|
|
|
|
|
|
|
} # else think of utf-8 |
255
|
5
|
|
|
|
|
12
|
utf8::decode($val); |
256
|
5
|
|
|
|
|
6
|
my $res = ''; |
257
|
5
|
|
|
|
|
16
|
foreach (0 .. length $val) { |
258
|
28
|
|
|
|
|
45
|
$_ = substr($val, $_, 1); |
259
|
28
|
100
|
|
|
|
72
|
$_ = $ml2icao{$_} if defined $ml2icao{$_}; |
260
|
28
|
|
|
|
|
42
|
$res .= $_; |
261
|
|
|
|
|
|
|
} |
262
|
5
|
|
|
|
|
28
|
return $res; |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
1; |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=head1 AUTHORS |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
Serguei Trouchelle EFE |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=head1 COPYRIGHT |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
Copyright (c) 2007-2009 Serguei Trouchelle. All rights reserved. |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
276
|
|
|
|
|
|
|
under the same terms as Perl itself. |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=head1 SEE ALSO |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
Lingua::Cyrillic::Translit::ICAO -- Cyrillic characters transliteration into ICAO Doc 9303 |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=cut |