| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Lingua/Cyrillic/Translit/ICAO.pm |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# $Id: ICAO.pm 7 2009-09-16 15:41:34Z 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.03 2007/07/05 use 5.8.0 added |
|
17
|
|
|
|
|
|
|
# 1.02 2007/07/04 POD fixes |
|
18
|
|
|
|
|
|
|
# 1.01 2007/07/02 Initial revision |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Lingua::Cyrillic::Translit::ICAO -- Cyrillic characters transliteration into ICAO Doc 9303 |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Lingua::Cyrillic::Translit::ICAO qw/ cyr2icao /; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
print cyr2icao('ukrainian', 'koi8-r'); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Lingua::Cyrillic::Translit::ICAO can be used for transliteration of Cyrillic |
|
33
|
|
|
|
|
|
|
characters in conformance with ICAO Doc 9303 Recommendations. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 METHODS |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
package Lingua::Cyrillic::Translit::ICAO; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
require Exporter; |
|
42
|
3
|
|
|
3
|
|
21301
|
use Config; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
187
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
3
|
|
|
3
|
|
16
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
86
|
|
|
45
|
3
|
|
|
3
|
|
23
|
use warnings; |
|
|
3
|
|
|
|
|
97
|
|
|
|
3
|
|
|
|
|
85
|
|
|
46
|
3
|
|
|
3
|
|
55
|
use 5.008; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
113
|
|
|
47
|
3
|
|
|
3
|
|
2383
|
use utf8; |
|
|
3
|
|
|
|
|
19
|
|
|
|
3
|
|
|
|
|
13
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
3
|
|
|
3
|
|
2725
|
use Encode; |
|
|
3
|
|
|
|
|
37681
|
|
|
|
3
|
|
|
|
|
2346
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
our @EXPORT = qw/ /; |
|
52
|
|
|
|
|
|
|
our @EXPORT_OK = qw/ cyr2icao /; |
|
53
|
|
|
|
|
|
|
our %EXPORT_TAGS = qw / /; |
|
54
|
|
|
|
|
|
|
our @ISA = qw/Exporter/; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
our $VERSION = '1.05'; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $table = q!1 1 |
|
59
|
|
|
|
|
|
|
А A |
|
60
|
|
|
|
|
|
|
Б B |
|
61
|
|
|
|
|
|
|
В V |
|
62
|
|
|
|
|
|
|
Г G |
|
63
|
|
|
|
|
|
|
Д D |
|
64
|
|
|
|
|
|
|
Е E |
|
65
|
|
|
|
|
|
|
Ё E |
|
66
|
|
|
|
|
|
|
Ж ZH |
|
67
|
|
|
|
|
|
|
З Z |
|
68
|
|
|
|
|
|
|
И I |
|
69
|
|
|
|
|
|
|
І I |
|
70
|
|
|
|
|
|
|
Й I |
|
71
|
|
|
|
|
|
|
К K |
|
72
|
|
|
|
|
|
|
Л L |
|
73
|
|
|
|
|
|
|
М M |
|
74
|
|
|
|
|
|
|
Н N |
|
75
|
|
|
|
|
|
|
О O |
|
76
|
|
|
|
|
|
|
П P |
|
77
|
|
|
|
|
|
|
Р R |
|
78
|
|
|
|
|
|
|
С S |
|
79
|
|
|
|
|
|
|
Т T |
|
80
|
|
|
|
|
|
|
У U |
|
81
|
|
|
|
|
|
|
Ф F |
|
82
|
|
|
|
|
|
|
Х KH |
|
83
|
|
|
|
|
|
|
Ц TS |
|
84
|
|
|
|
|
|
|
Ч CH |
|
85
|
|
|
|
|
|
|
Ш SH |
|
86
|
|
|
|
|
|
|
Щ SHCH |
|
87
|
|
|
|
|
|
|
Ы Y |
|
88
|
|
|
|
|
|
|
Ѣ IE |
|
89
|
|
|
|
|
|
|
Э E |
|
90
|
|
|
|
|
|
|
Ю IU |
|
91
|
|
|
|
|
|
|
Я IA |
|
92
|
|
|
|
|
|
|
Ѵ Y |
|
93
|
|
|
|
|
|
|
Ґ G |
|
94
|
|
|
|
|
|
|
Ў U |
|
95
|
|
|
|
|
|
|
Ѫ U |
|
96
|
|
|
|
|
|
|
Ѓ G |
|
97
|
|
|
|
|
|
|
Ђ D |
|
98
|
|
|
|
|
|
|
Ѕ DZ |
|
99
|
|
|
|
|
|
|
Ј J |
|
100
|
|
|
|
|
|
|
Ќ K |
|
101
|
|
|
|
|
|
|
Љ LJ |
|
102
|
|
|
|
|
|
|
Њ NJ |
|
103
|
|
|
|
|
|
|
Һ C |
|
104
|
|
|
|
|
|
|
Џ DZ |
|
105
|
|
|
|
|
|
|
Є IE |
|
106
|
|
|
|
|
|
|
Ї I |
|
107
|
|
|
|
|
|
|
а a |
|
108
|
|
|
|
|
|
|
б b |
|
109
|
|
|
|
|
|
|
в v |
|
110
|
|
|
|
|
|
|
г g |
|
111
|
|
|
|
|
|
|
д d |
|
112
|
|
|
|
|
|
|
е e |
|
113
|
|
|
|
|
|
|
ё e |
|
114
|
|
|
|
|
|
|
ж zh |
|
115
|
|
|
|
|
|
|
з z |
|
116
|
|
|
|
|
|
|
и i |
|
117
|
|
|
|
|
|
|
і i |
|
118
|
|
|
|
|
|
|
й i |
|
119
|
|
|
|
|
|
|
к k |
|
120
|
|
|
|
|
|
|
л l |
|
121
|
|
|
|
|
|
|
м m |
|
122
|
|
|
|
|
|
|
н n |
|
123
|
|
|
|
|
|
|
о o |
|
124
|
|
|
|
|
|
|
п p |
|
125
|
|
|
|
|
|
|
р r |
|
126
|
|
|
|
|
|
|
с s |
|
127
|
|
|
|
|
|
|
т t |
|
128
|
|
|
|
|
|
|
у u |
|
129
|
|
|
|
|
|
|
ф f |
|
130
|
|
|
|
|
|
|
х kh |
|
131
|
|
|
|
|
|
|
ц ts |
|
132
|
|
|
|
|
|
|
ч ch |
|
133
|
|
|
|
|
|
|
ш sh |
|
134
|
|
|
|
|
|
|
щ shch |
|
135
|
|
|
|
|
|
|
ы y |
|
136
|
|
|
|
|
|
|
ѣ ie |
|
137
|
|
|
|
|
|
|
э e |
|
138
|
|
|
|
|
|
|
ю iu |
|
139
|
|
|
|
|
|
|
я ia |
|
140
|
|
|
|
|
|
|
ѵ y |
|
141
|
|
|
|
|
|
|
ґ g |
|
142
|
|
|
|
|
|
|
ў u |
|
143
|
|
|
|
|
|
|
ѫ u |
|
144
|
|
|
|
|
|
|
ѓ g |
|
145
|
|
|
|
|
|
|
ђ d |
|
146
|
|
|
|
|
|
|
ѕ dz |
|
147
|
|
|
|
|
|
|
ј j |
|
148
|
|
|
|
|
|
|
ќ k |
|
149
|
|
|
|
|
|
|
љ lj |
|
150
|
|
|
|
|
|
|
њ nj |
|
151
|
|
|
|
|
|
|
һ c |
|
152
|
|
|
|
|
|
|
џ dz |
|
153
|
|
|
|
|
|
|
є ie |
|
154
|
|
|
|
|
|
|
ї i |
|
155
|
|
|
|
|
|
|
2 2!; |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
our %cyr2icao = split /\s+/, $table; |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
# skip hard and soft signs |
|
160
|
|
|
|
|
|
|
$cyr2icao{'Ъ'} = ''; |
|
161
|
|
|
|
|
|
|
$cyr2icao{'ъ'} = ''; |
|
162
|
|
|
|
|
|
|
$cyr2icao{'Ь'} = ''; |
|
163
|
|
|
|
|
|
|
$cyr2icao{'ь'} = ''; |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 cyr2icao ( $string, [$language], [ $encoding ]) |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This method converts $string from Cyrillic character set to ICAO transliteration. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Optional $language parameter allow to specify $string's language. Valid values are: |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=over 1 |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item 'by' - Belorussian |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item 'bu' - Bulgarian |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item 'mk' - Macedonian |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item 'uk' - Ukrainian |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=back |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Other values are accepted but do not affect anything. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Optional $encoding parameter allows to specify $string's encoding (default is 'utf-8') |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=cut |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub cyr2icao { |
|
190
|
6
|
|
|
6
|
1
|
29
|
my $val = shift; |
|
191
|
6
|
|
|
|
|
11
|
my $lang = shift; |
|
192
|
6
|
|
|
|
|
9
|
my $enc = shift; |
|
193
|
6
|
50
|
|
|
|
19
|
if ($enc) { |
|
194
|
6
|
|
|
|
|
24
|
$val = Encode::decode($enc, $val); |
|
195
|
|
|
|
|
|
|
} # else think of utf-8 |
|
196
|
6
|
|
|
|
|
8015
|
utf8::decode($val); |
|
197
|
6
|
|
|
|
|
14
|
my $res = ''; |
|
198
|
6
|
|
|
|
|
24
|
foreach (0 .. length $val) { |
|
199
|
42
|
|
|
|
|
66
|
$_ = substr($val, $_, 1); |
|
200
|
42
|
0
|
0
|
|
|
86
|
$_ = 'H' if $_ eq 'Г' and ($lang eq 'by' or $lang eq 'mk'); |
|
|
|
|
33
|
|
|
|
|
|
201
|
42
|
0
|
0
|
|
|
70
|
$_ = 'h' if $_ eq 'г' and ($lang eq 'by' or $lang eq 'mk'); |
|
|
|
|
33
|
|
|
|
|
|
202
|
42
|
50
|
33
|
|
|
87
|
$_ = 'IO' if $_ eq 'Ё' and $lang eq 'by'; |
|
203
|
42
|
50
|
33
|
|
|
75
|
$_ = 'io' if $_ eq 'ё' and $lang eq 'by'; |
|
204
|
42
|
50
|
33
|
|
|
83
|
$_ = 'Z' if $_ eq 'Ж' and $lang eq 'mk'; |
|
205
|
42
|
50
|
33
|
|
|
77
|
$_ = 'z' if $_ eq 'ж' and $lang eq 'mk'; |
|
206
|
42
|
50
|
33
|
|
|
85
|
$_ = 'Y' if $_ eq 'И' and $lang eq 'uk'; |
|
207
|
42
|
100
|
66
|
|
|
157
|
$_ = 'y' if $_ eq 'и' and $lang eq 'uk'; |
|
208
|
42
|
50
|
33
|
|
|
81
|
$_ = 'H' if $_ eq 'Х' and $lang eq 'mk'; |
|
209
|
42
|
50
|
33
|
|
|
83
|
$_ = 'h' if $_ eq 'х' and $lang eq 'mk'; |
|
210
|
42
|
50
|
33
|
|
|
78
|
$_ = 'C' if $_ eq 'Ц' and $lang eq 'mk'; |
|
211
|
42
|
50
|
66
|
|
|
89
|
$_ = 'c' if $_ eq 'ц' and $lang eq 'mk'; |
|
212
|
42
|
50
|
33
|
|
|
80
|
$_ = 'C' if $_ eq 'Ч' and $lang eq 'mk'; |
|
213
|
42
|
50
|
33
|
|
|
80
|
$_ = 'c' if $_ eq 'ч' and $lang eq 'mk'; |
|
214
|
42
|
50
|
33
|
|
|
88
|
$_ = 'S' if $_ eq 'Ш' and $lang eq 'mk'; |
|
215
|
42
|
50
|
66
|
|
|
84
|
$_ = 's' if $_ eq 'ш' and $lang eq 'mk'; |
|
216
|
42
|
50
|
33
|
|
|
85
|
$_ = 'SHT' if $_ eq 'Щ' and $lang eq 'bg'; |
|
217
|
42
|
50
|
33
|
|
|
86
|
$_ = 'sht' if $_ eq 'щ' and $lang eq 'bg'; |
|
218
|
|
|
|
|
|
|
|
|
219
|
42
|
100
|
|
|
|
261
|
$_ = $cyr2icao{$_} if defined $cyr2icao{$_}; |
|
220
|
42
|
|
|
|
|
74
|
$res .= $_; |
|
221
|
|
|
|
|
|
|
} |
|
222
|
6
|
|
|
|
|
35
|
return $res; |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
1; |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 AUTHORS |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Serguei Trouchelle EFE |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Copyright (c) 2007 Serguei Trouchelle. All rights reserved. |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
236
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Lingua::RU::Translit - Transliteration of Russian text to Latin symbols. |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Lingua::UK::Translit - Transliteration of Ukrainian text to Latin symbols. |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=cut |