line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::RU::PhTranslit; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Lingua::RU::PhTranslit - Phonetic correct translit (for Cyrillic) |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Lingua::RU::PhTranslit |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
The folowing functions include in this package |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
koi2phtr, phtr2koi |
16
|
|
|
|
|
|
|
koi2win, win2koi |
17
|
|
|
|
|
|
|
koi2alt, alt2koi |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
koi - KOI8-R |
20
|
|
|
|
|
|
|
win - Windows-1251, CP1251 |
21
|
|
|
|
|
|
|
alt - CP866 |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sample script ------------------------------------------ |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Lingua::RU::PhTranslit; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $koi_string=" "; |
28
|
|
|
|
|
|
|
print koi2phtr("$koi_string\n"); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
script output ------------------------------------------ |
31
|
|
|
|
|
|
|
E'ta strochka napisana russkimi bukovkami |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
------------------------------------------------------- |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Main appointment of this package is converting information during |
36
|
|
|
|
|
|
|
export/import from/to mobile devices. On desktop computers this |
37
|
|
|
|
|
|
|
problem is not actul now. Transform in this pacage is bidirectional. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
P.S. Sorry for my English. It is not a native language for me. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 History |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
0.1 () - initial release; |
44
|
|
|
|
|
|
|
0.2 (2001-10-12) - correct "" in koi2win; |
45
|
|
|
|
|
|
|
0.3 (2003-03-28) - missing test added; |
46
|
|
|
|
|
|
|
0.4 (2003-04-10 - add some documentation, |
47
|
|
|
|
|
|
|
correct mistake with change $_ (thank's Sean M. Burke) |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
1
|
|
8716
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
52
|
1
|
|
|
1
|
|
10
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7716
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
require Exporter; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
@ISA = qw(Exporter AutoLoader); |
57
|
|
|
|
|
|
|
@EXPORT = qw( &koi2phtr &phtr2koi &koi2win &win2koi &koi2alt &alt2koi); |
58
|
|
|
|
|
|
|
#@EXPORT_OK = qw(); |
59
|
|
|
|
|
|
|
$VERSION = '0.4'; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub koi2phtr |
62
|
1
|
|
|
1
|
0
|
110
|
{ local ($_)=@_; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# |
65
|
|
|
|
|
|
|
# koi8-r to Phonetic correct translit |
66
|
|
|
|
|
|
|
# |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
4
|
s//S\'h/; s//s\'h/; s//S\'H/; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
69
|
1
|
|
|
|
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\'h/g; s//z\'h/g; s//Z\'H/g; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
90
|
1
|
|
|
|
|
2
|
s//Zh/g; s//zh/g; |
|
1
|
|
|
|
|
2
|
|
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
3
|
tr/ |
93
|
|
|
|
|
|
|
/ |
94
|
|
|
|
|
|
|
abvgdzijklmnoprstufhc\"y\'ABVGDZIJKLMNOPRSTUFHC\"Y\'/; |
95
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
5
|
return $_; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub phtr2koi |
101
|
1
|
|
|
1
|
0
|
3
|
{ local($_)=@_; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# |
104
|
|
|
|
|
|
|
# Phonetic correct translit to koi8-r |
105
|
|
|
|
|
|
|
# |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
2
|
s/E\'//g; s/e\'//g; |
|
1
|
|
|
|
|
2
|
|
108
|
1
|
|
|
|
|
4
|
s/E//g; s/e//g; |
|
1
|
|
|
|
|
1
|
|
109
|
|
|
|
|
|
|
|
110
|
1
|
|
|
|
|
3
|
s/Jo//g; s/jo//g; |
|
1
|
|
|
|
|
3
|
|
111
|
1
|
|
|
|
|
2
|
s/J\'o//g; s/j\'o//g; s/J\'O//g; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
112
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
2
|
s/Sch//g; s/sch//g; |
|
1
|
|
|
|
|
1
|
|
114
|
1
|
|
|
|
|
2
|
s/Sc\'h//g; s/sc\'h//g; s/SC\'H//g; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1
|
|
115
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
2
|
s/Ch//g; s/ch//g; |
|
1
|
|
|
|
|
22
|
|
117
|
1
|
|
|
|
|
2
|
s/C\'h//g; s/c\'h//g; s/C\'H//g; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
118
|
|
|
|
|
|
|
|
119
|
1
|
|
|
|
|
2
|
s/Sh//g; s/sh//g; |
|
1
|
|
|
|
|
2
|
|
120
|
1
|
|
|
|
|
1
|
s/S\'h//g; s/s\'h//g; s/S\'H//g; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
121
|
|
|
|
|
|
|
|
122
|
1
|
|
|
|
|
2
|
s/Ja//g; s/ja//g; |
|
1
|
|
|
|
|
8
|
|
123
|
1
|
|
|
|
|
2
|
s/J\'a//g; s/j\'a//g; s/J\'A//g; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
124
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
2
|
s/Zh//g; s/zh//g; |
|
1
|
|
|
|
|
1
|
|
126
|
1
|
|
|
|
|
3
|
s/Z\'h//g; s/z\'h//g; s/Z\'H//g; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
127
|
|
|
|
|
|
|
|
128
|
1
|
|
|
|
|
1
|
s/Ju//g; s/ju//g; |
|
1
|
|
|
|
|
2
|
|
129
|
1
|
|
|
|
|
2
|
s/J\'u//g; s/j\'u//g; s/J\'U//g; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
1
|
|
|
|
|
1
|
tr/ |
133
|
|
|
|
|
|
|
abvgdzijklmnoprstufhc\"y\'ABVGDZIJKLMNOPRSTUFHC\"Y\'/ |
134
|
|
|
|
|
|
|
/; |
135
|
|
|
|
|
|
|
|
136
|
1
|
|
|
|
|
4
|
return $_; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# |
141
|
|
|
|
|
|
|
# Next functions added for Windows users |
142
|
|
|
|
|
|
|
# Each function translate "\n" to "\n" - this in no bug. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub koi2win |
145
|
1
|
|
|
1
|
0
|
2
|
{ local($_)=@_; |
146
|
|
|
|
|
|
|
|
147
|
1
|
|
|
|
|
3
|
tr/ |
148
|
|
|
|
|
|
|
ţ/ |
149
|
|
|
|
|
|
|
Ũ/;
|
150
|
1
|
|
|
|
|
3
|
return $_; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub win2koi |
154
|
1
|
|
|
1
|
0
|
2
|
{ local($_)=@_; |
155
|
|
|
|
|
|
|
|
156
|
1
|
|
|
|
|
2
|
tr/ |
157
|
|
|
|
|
|
|
Ũ/ |
158
|
|
|
|
|
|
|
ţ/;
|
159
|
1
|
|
|
|
|
8
|
return $_; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
}
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub alt2koi |
164
|
1
|
|
|
1
|
0
|
2
|
{ local($_)=@_; |
165
|
|
|
|
|
|
|
|
166
|
1
|
|
|
|
|
1
|
tr/ |
167
|
|
|
|
|
|
|
/ |
168
|
|
|
|
|
|
|
Ѐъ/; |
169
|
1
|
|
|
|
|
4
|
return $_; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
}
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub koi2alt |
174
|
1
|
|
|
1
|
0
|
3
|
{ local($_)=@_; |
175
|
|
|
|
|
|
|
|
176
|
1
|
|
|
|
|
2
|
tr/ |
177
|
|
|
|
|
|
|
Ѐъ/ |
178
|
|
|
|
|
|
|
/; |
179
|
1
|
|
|
|
|
3
|
return $_; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
}
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
1; |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
__END__ |