line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::RU::Charset; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
################################################################################ |
4
|
|
|
|
|
|
|
# Nothing is exported by def. - use :CHARSET, :CONVERT, :CHARCASE or sub names # |
5
|
|
|
|
|
|
|
################################################################################ |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1157
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
8
|
1
|
|
|
1
|
|
6
|
use vars qw ($VERSION @ISA @EXPORT_OK %EXPORT_TAGS); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2703
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$VERSION = 0.02; |
12
|
|
|
|
|
|
|
@ISA = qw (Exporter); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
@EXPORT_OK = qw (ENG KOI WIN ALT ISO MAC RUS UNI UTF charset |
15
|
|
|
|
|
|
|
any2koi win2koi alt2koi iso2koi mac2koi rus2koi uni2koi utf2koi |
16
|
|
|
|
|
|
|
koi2win any2win alt2win iso2win mac2win rus2win uni2win utf2win |
17
|
|
|
|
|
|
|
koi2alt win2alt any2alt iso2alt mac2alt rus2alt uni2alt utf2alt |
18
|
|
|
|
|
|
|
koi2iso win2iso alt2iso any2iso mac2iso rus2iso uni2iso utf2iso |
19
|
|
|
|
|
|
|
koi2mac win2mac alt2mac iso2mac any2mac rus2mac uni2mac utf2mac |
20
|
|
|
|
|
|
|
koi2rus win2rus alt2rus iso2rus mac2rus any2rus uni2rus utf2rus |
21
|
|
|
|
|
|
|
koi2uni win2uni alt2uni iso2uni mac2uni rus2uni any2uni utf2uni |
22
|
|
|
|
|
|
|
koi2utf win2utf alt2utf iso2utf mac2utf rus2utf uni2utf any2utf |
23
|
|
|
|
|
|
|
koi2lc win2lc alt2lc iso2lc mac2lc rus2lc uni2lc utf2lc |
24
|
|
|
|
|
|
|
koi2uc win2uc alt2uc iso2uc mac2uc rus2uc uni2uc utf2uc); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
%EXPORT_TAGS = (CHARSET => [ qw (ENG KOI WIN ALT ISO MAC RUS UNI UTF charset) ], |
27
|
|
|
|
|
|
|
CONVERT => [ qw (any2koi win2koi alt2koi iso2koi mac2koi rus2koi uni2koi utf2koi |
28
|
|
|
|
|
|
|
koi2win any2win alt2win iso2win mac2win rus2win uni2win utf2win |
29
|
|
|
|
|
|
|
koi2alt win2alt any2alt iso2alt mac2alt rus2alt uni2alt utf2alt |
30
|
|
|
|
|
|
|
koi2iso win2iso alt2iso any2iso mac2iso rus2iso uni2iso utf2iso |
31
|
|
|
|
|
|
|
koi2mac win2mac alt2mac iso2mac any2mac rus2mac uni2mac utf2mac |
32
|
|
|
|
|
|
|
koi2rus win2rus alt2rus iso2rus mac2rus any2rus uni2rus utf2rus |
33
|
|
|
|
|
|
|
koi2uni win2uni alt2uni iso2uni mac2uni rus2uni any2uni utf2uni |
34
|
|
|
|
|
|
|
koi2utf win2utf alt2utf iso2utf mac2utf rus2utf uni2utf any2utf) ], |
35
|
|
|
|
|
|
|
CHARCASE => [ qw (koi2lc win2lc alt2lc iso2lc mac2lc rus2lc uni2lc utf2lc |
36
|
|
|
|
|
|
|
koi2uc win2uc alt2uc iso2uc mac2uc rus2uc uni2uc utf2uc) ]); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
################################################################################ |
40
|
|
|
|
|
|
|
# Hash tables with frequencies of russian letter pairs # |
41
|
|
|
|
|
|
|
################################################################################ |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my (%KOI, %WIN, %ALT, %ISO, %MAC, %RUS, %UNI, %UTF); # TODO |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
################################################################################ |
46
|
|
|
|
|
|
|
# Define charsets returned by the charset subroutine below # |
47
|
|
|
|
|
|
|
################################################################################ |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
0
|
0
|
|
sub ENG { 0 } # unknown charset |
50
|
0
|
|
|
0
|
0
|
|
sub KOI { 1 } # KOI8-r |
51
|
0
|
|
|
0
|
0
|
|
sub WIN { 2 } # Windows-1251 |
52
|
0
|
|
|
0
|
0
|
|
sub ALT { 3 } # CP866 |
53
|
0
|
|
|
0
|
0
|
|
sub ISO { 4 } # ISO-8859-5 |
54
|
0
|
|
|
0
|
0
|
|
sub MAC { 5 } # X-Mac-Cyrillic |
55
|
0
|
|
|
0
|
0
|
|
sub RUS { 6 } # russian text in english letters |
56
|
0
|
|
|
0
|
0
|
|
sub UNI { 7 } # Unicode |
57
|
0
|
|
|
0
|
0
|
|
sub UTF { 8 } # UTF-8 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
################################################################################ |
60
|
|
|
|
|
|
|
# Try detecting charset by counting pairs of russian letters # |
61
|
|
|
|
|
|
|
################################################################################ |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
0
|
0
|
|
sub charset { 0 } # TODO |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
################################################################################ |
66
|
|
|
|
|
|
|
# Convert a KOI8-r string or a list of strings into the Windows-1251 charset # |
67
|
|
|
|
|
|
|
################################################################################ |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub koi2win |
70
|
|
|
|
|
|
|
{ |
71
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
map { tr/\xA3\xB3\xC0-\xFF/\xB8\xA8\xFE\xE0\xE1\xF6\xE4\xE5\xF4\xE3\xF5\xE8-\xEF\xFF\xF0-\xF3\xE6\xE2\xFC\xFB\xE7\xF8\xFD\xF9\xF7\xFA\xDE\xC0\xC1\xD6\xC4\xC5\xD4\xC3\xD5\xC8-\xCF\xDF\xD0-\xD3\xC6\xC2\xDC\xDB\xC7\xD8\xDD\xD9\xD7\xDA/ } @str; |
|
0
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return @str; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
################################################################################ |
79
|
|
|
|
|
|
|
# Convert a Windows-1251 string or a list of strings into the KOI8-r charset # |
80
|
|
|
|
|
|
|
################################################################################ |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub win2koi |
83
|
|
|
|
|
|
|
{ |
84
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
map { tr/\xB8\xA8\xFE\xE0\xE1\xF6\xE4\xE5\xF4\xE3\xF5\xE8-\xEF\xFF\xF0-\xF3\xE6\xE2\xFC\xFB\xE7\xF8\xFD\xF9\xF7\xFA\xDE\xC0\xC1\xD6\xC4\xC5\xD4\xC3\xD5\xC8-\xCF\xDF\xD0-\xD3\xC6\xC2\xDC\xDB\xC7\xD8\xDD\xD9\xD7\xDA/\xA3\xB3\xC0-\xFF/ } @str; |
|
0
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return @str; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
################################################################################ |
92
|
|
|
|
|
|
|
# Convert a KOI8-r string or a list of strings into the CP-866 charset # |
93
|
|
|
|
|
|
|
################################################################################ |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub koi2alt |
96
|
|
|
|
|
|
|
{ |
97
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
map { tr/\xA3\xB3\xC0-\xFF/\xF1\xF0\xEE\xA0\xA1\xE6\xA4\xA5\xE4\xA3\xE5\xA8-\xAF\xEF\xE0-\xE3\xA6\xA2\xEC\xEB\xA7\xE8\xED\xE9\xE7\xEA\x9E\x80\x81\x96\x84\x85\x94\x83\x95\x88-\x8F\x9F\x90-\x93\x86\x82\x9C\x9B\x87\x98\x9D\x99\x97\x9A/ } @str; |
|
0
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
return @str; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
################################################################################ |
105
|
|
|
|
|
|
|
# Convert a CP-866 string or a list of strings into the KOI8-r charset # |
106
|
|
|
|
|
|
|
################################################################################ |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub alt2koi |
109
|
|
|
|
|
|
|
{ |
110
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
map { tr/\xF1\xF0\xEE\xA0\xA1\xE6\xA4\xA5\xE4\xA3\xE5\xA8-\xAF\xEF\xE0-\xE3\xA6\xA2\xEC\xEB\xA7\xE8\xED\xE9\xE7\xEA\x9E\x80\x81\x96\x84\x85\x94\x83\x95\x88-\x8F\x9F\x90-\x93\x86\x82\x9C\x9B\x87\x98\x9D\x99\x97\x9A/\xA3\xB3\xC0-\xFF/ } @str; |
|
0
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
return @str; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
################################################################################ |
118
|
|
|
|
|
|
|
# Convert a KOI8-r string or a list of strings into the ISO-8859-5 charset # |
119
|
|
|
|
|
|
|
################################################################################ |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub koi2iso |
122
|
|
|
|
|
|
|
{ |
123
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
map { tr/\xA3\xB3\xC0-\xFF/\xF1\xA1\xEE\xD0\xD1\xE6\xD4\xD5\xE4\xD3\xE5\xD8-\xDF\xEF\xE0-\xE3\xD6\xD2\xEC\xEB\xD7\xE8\xED\xE9\xE7\xEA\xCE\xB0\xB1\xC6\xB4\xB5\xC4\xB3\xC5\xB8-\xBF\xCF\xC0-\xC3\xB6\xB2\xCC\xCB\xB7\xC8\xCD\xC9\xC7\xCA/ } @str; |
|
0
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
return @str; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
################################################################################ |
131
|
|
|
|
|
|
|
# Convert a ISO-8859-5 string or a list of strings into the KOI8-r charset # |
132
|
|
|
|
|
|
|
################################################################################ |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub iso2koi |
135
|
|
|
|
|
|
|
{ |
136
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
map { tr/\xF1\xA1\xEE\xD0\xD1\xE6\xD4\xD5\xE4\xD3\xE5\xD8-\xDF\xEF\xE0-\xE3\xD6\xD2\xEC\xEB\xD7\xE8\xED\xE9\xE7\xEA\xCE\xB0\xB1\xC6\xB4\xB5\xC4\xB3\xC5\xB8-\xBF\xCF\xC0-\xC3\xB6\xB2\xCC\xCB\xB7\xC8\xCD\xC9\xC7\xCA/\xA3\xB3\xC0-\xFF/ } @str; |
|
0
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
return @str; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
################################################################################ |
144
|
|
|
|
|
|
|
# Convert a KOI8-r string or a list of strings into the X-Mac-Cyrillic charset # |
145
|
|
|
|
|
|
|
################################################################################ |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub koi2mac |
148
|
|
|
|
|
|
|
{ |
149
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
map { tr/\xA3\xB3\xC0-\xFF/\xDE\xDD\xFE\xE0\xE1\xF6\xE4\xE5\xF4\xE3\xF5\xE8-\xEF\xDF\xF0-\xF3\xE6\xE2\xFC\xFB\xE7\xF8\xFD\xF9\xF7\xFA\x9E\x80\x81\x96\x84\x85\x94\x83\x95\x88-\x8F\x9F\x90-\x93\x86\x82\x9C\x9B\x87\x98\x9D\x99\x97\x9A/ } @str; |
|
0
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
return @str; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
################################################################################ |
157
|
|
|
|
|
|
|
# Convert a X-Mac-Cyrillic string or a list of strings into the KOI8-r charset # |
158
|
|
|
|
|
|
|
################################################################################ |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub mac2koi |
161
|
|
|
|
|
|
|
{ |
162
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
163
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
|
map { tr/\xDE\xDD\xFE\xE0\xE1\xF6\xE4\xE5\xF4\xE3\xF5\xE8-\xEF\xDF\xF0-\xF3\xE6\xE2\xFC\xFB\xE7\xF8\xFD\xF9\xF7\xFA\x9E\x80\x81\x96\x84\x85\x94\x83\x95\x88-\x8F\x9F\x90-\x93\x86\x82\x9C\x9B\x87\x98\x9D\x99\x97\x9A/\xA3\xB3\xC0-\xFF/ } @str; |
|
0
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
return @str; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
################################################################################ |
170
|
|
|
|
|
|
|
# Convert a KOI8-r string or a list of strings into the "russkij" charset # |
171
|
|
|
|
|
|
|
################################################################################ |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub koi2rus |
174
|
|
|
|
|
|
|
{ |
175
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
176
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
map { tr/\xA3\xB3\xC1-\xD0\xD2-\xD5\xD7-\xDA\xDC\xDF\xE1-\xF0\xF2-\xF5\xF7-\xFA\xFC\xFF/eEabcdefgxijklmnoprstuv`ize'ABCDEFGXIJKLMNOPRSTUV`IZE'/ } @str; |
|
0
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
map { s/\xC0/ju/g } @str; |
|
0
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
map { s/\xD1/ja/g } @str; |
|
0
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
map { s/\xD6/zh/g } @str; |
|
0
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
map { s/\xDB/sh/g } @str; |
|
0
|
|
|
|
|
|
|
183
|
0
|
|
|
|
|
|
map { s/\xDD/sch/g } @str; |
|
0
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
map { s/\xDE/ch/g } @str; |
|
0
|
|
|
|
|
|
|
185
|
0
|
|
|
|
|
|
map { s/\xE0/Ju/g } @str; |
|
0
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
map { s/\xF1/Ja/g } @str; |
|
0
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
map { s/\xF6/Zh/g } @str; |
|
0
|
|
|
|
|
|
|
188
|
0
|
|
|
|
|
|
map { s/\xFB/Sh/g } @str; |
|
0
|
|
|
|
|
|
|
189
|
0
|
|
|
|
|
|
map { s/\xFD/Sch/g } @str; |
|
0
|
|
|
|
|
|
|
190
|
0
|
|
|
|
|
|
map { s/\xFE/Ch/g } @str; |
|
0
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
|
return @str; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
################################################################################ |
196
|
|
|
|
|
|
|
# Convert a "russkij" string or a list of strings into the KOI8-r charset # |
197
|
|
|
|
|
|
|
################################################################################ |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub rus2koi |
200
|
|
|
|
|
|
|
{ |
201
|
0
|
|
|
0
|
0
|
|
@_; # TODO |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
################################################################################ |
205
|
|
|
|
|
|
|
# Convert a KOI8-r string or a list of strings to lower case # |
206
|
|
|
|
|
|
|
################################################################################ |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub koi2lc |
209
|
|
|
|
|
|
|
{ |
210
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
211
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
|
map { tr/\xB3\xE0-\xFF/\xA3\xC0-\xDF/ } @str; |
|
0
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
return @str; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
################################################################################ |
218
|
|
|
|
|
|
|
# Convert a KOI8-r string or a list of strings to upper case # |
219
|
|
|
|
|
|
|
################################################################################ |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub koi2uc |
222
|
|
|
|
|
|
|
{ |
223
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
224
|
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
|
map { tr/\xA3\xC0-\xDF/\xB3\xE0-\xFF/ } @str; |
|
0
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
|
return @str; |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
################################################################################ |
231
|
|
|
|
|
|
|
# Convert a Windows-1251 string or a list of strings to lower case # |
232
|
|
|
|
|
|
|
################################################################################ |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
sub win2lc |
235
|
|
|
|
|
|
|
{ |
236
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
237
|
|
|
|
|
|
|
|
238
|
0
|
|
|
|
|
|
map { tr/\xA8\xC0-\xDF/\xB8\xE0-\xFF/ } @str; |
|
0
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
|
240
|
0
|
|
|
|
|
|
return @str; |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
################################################################################ |
244
|
|
|
|
|
|
|
# Convert a Windows-1251 string or a list of strings to upper case # |
245
|
|
|
|
|
|
|
################################################################################ |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
sub win2uc |
248
|
|
|
|
|
|
|
{ |
249
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
250
|
|
|
|
|
|
|
|
251
|
0
|
|
|
|
|
|
map { tr/\xB8\xE0-\xFF/\xA8\xC0-\xDF/ } @str; |
|
0
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
|
253
|
0
|
|
|
|
|
|
return @str; |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
################################################################################ |
257
|
|
|
|
|
|
|
# Convert a CP-866 string or a list of strings to lower case # |
258
|
|
|
|
|
|
|
################################################################################ |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
sub alt2lc |
261
|
|
|
|
|
|
|
{ |
262
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
263
|
|
|
|
|
|
|
|
264
|
0
|
|
|
|
|
|
map { tr/\xF0\x80-\x9F/\xF1\xA0-\xAF\xE0-\xEF/ } @str; |
|
0
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
|
266
|
0
|
|
|
|
|
|
return @str; |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
################################################################################ |
270
|
|
|
|
|
|
|
# Convert a CP-866 string or a list of strings to upper case # |
271
|
|
|
|
|
|
|
################################################################################ |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
sub alt2uc |
274
|
|
|
|
|
|
|
{ |
275
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
276
|
|
|
|
|
|
|
|
277
|
0
|
|
|
|
|
|
map { tr/\xF1\xA0-\xAF\xE0-\xEF/\xF0\x80-\x9F/ } @str; |
|
0
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
|
279
|
0
|
|
|
|
|
|
return @str; |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
################################################################################ |
283
|
|
|
|
|
|
|
# Convert a ISO-8859-5 string or a list of strings to lower case # |
284
|
|
|
|
|
|
|
################################################################################ |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
sub iso2lc |
287
|
|
|
|
|
|
|
{ |
288
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
289
|
|
|
|
|
|
|
|
290
|
0
|
|
|
|
|
|
map { tr/\xA1\xB0-\xCF/\xF1\xD0-\xEF/ } @str; |
|
0
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
|
292
|
0
|
|
|
|
|
|
return @str; |
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
################################################################################ |
296
|
|
|
|
|
|
|
# Convert a ISO-8859-5 string or a list of strings to upper case # |
297
|
|
|
|
|
|
|
################################################################################ |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
sub iso2uc |
300
|
|
|
|
|
|
|
{ |
301
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
302
|
|
|
|
|
|
|
|
303
|
0
|
|
|
|
|
|
map { tr/\xF1\xD0-\xEF/\xA1\xB0-\xCF/ } @str; |
|
0
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
|
305
|
0
|
|
|
|
|
|
return @str; |
306
|
|
|
|
|
|
|
} |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
################################################################################ |
309
|
|
|
|
|
|
|
# Convert a X-Mac-Cyrillic string or a list of strings to lower case # |
310
|
|
|
|
|
|
|
################################################################################ |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
sub mac2lc |
313
|
|
|
|
|
|
|
{ |
314
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
315
|
|
|
|
|
|
|
|
316
|
0
|
|
|
|
|
|
map { tr/\xDD\x80-\xDF/\xDE\xE0-\xFE\xDF/ } @str; |
|
0
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
|
318
|
0
|
|
|
|
|
|
return @str; |
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
################################################################################ |
322
|
|
|
|
|
|
|
# Convert a X-Mac-Cyrillic string or a list of strings to upper case # |
323
|
|
|
|
|
|
|
################################################################################ |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
sub mac2uc |
326
|
|
|
|
|
|
|
{ |
327
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
328
|
|
|
|
|
|
|
|
329
|
0
|
|
|
|
|
|
map { tr/\xDE\xE0-\xFE\xDF/\xDD\x80-\xDF/ } @str; |
|
0
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
|
331
|
0
|
|
|
|
|
|
return @str; |
332
|
|
|
|
|
|
|
} |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
################################################################################ |
335
|
|
|
|
|
|
|
# Convert a "russkij" string or a list of strings to lower case # |
336
|
|
|
|
|
|
|
################################################################################ |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
sub rus2lc |
339
|
|
|
|
|
|
|
{ |
340
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
341
|
|
|
|
|
|
|
|
342
|
0
|
|
|
|
|
|
map { tr/A-Z/a-z/ } @str; |
|
0
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
|
344
|
0
|
|
|
|
|
|
return @str; # TODO |
345
|
|
|
|
|
|
|
} |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
################################################################################ |
348
|
|
|
|
|
|
|
# Convert a "russkij" string or a list of strings to upper case # |
349
|
|
|
|
|
|
|
################################################################################ |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
sub rus2uc |
352
|
|
|
|
|
|
|
{ |
353
|
0
|
|
|
0
|
0
|
|
my @str = @_; # copy the arguments |
354
|
|
|
|
|
|
|
|
355
|
0
|
|
|
|
|
|
map { tr/a-z/A-Z/ } @str; |
|
0
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
|
357
|
0
|
|
|
|
|
|
return @str; # TODO |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
################################################################################ |
361
|
|
|
|
|
|
|
# Convert a Unicode string or a list of strings to lower case # |
362
|
|
|
|
|
|
|
################################################################################ |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
sub uni2lc # modify last byte |
365
|
|
|
|
|
|
|
{ |
366
|
0
|
|
|
0
|
0
|
|
my $byte; |
367
|
0
|
|
|
|
|
|
my @str = @_; # copy the arguments |
368
|
|
|
|
|
|
|
|
369
|
0
|
0
|
|
|
|
|
map { s#\G(.)(.)# $byte = $2; $byte =~ tr/\x01\x10-\x2F/\x51\x30-\x4F/; $1 != 0x4F ? "$1$2" : "$1$byte" #esg } @str; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
|
371
|
0
|
|
|
|
|
|
return @str; |
372
|
|
|
|
|
|
|
} |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
################################################################################ |
375
|
|
|
|
|
|
|
# Convert a Unicode string or a list of strings to upper case # |
376
|
|
|
|
|
|
|
################################################################################ |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
sub uni2uc |
379
|
|
|
|
|
|
|
{ |
380
|
0
|
|
|
0
|
0
|
|
my $byte; |
381
|
0
|
|
|
|
|
|
my @str = @_; # copy the arguments |
382
|
|
|
|
|
|
|
|
383
|
0
|
0
|
|
|
|
|
map { s#\G(.)(.)# $byte = $2; $byte =~ tr/\x51\x30-\x4F/\x01\x10-\x2F/; $1 != 0x4F ? "$1$2" : "$1$byte" #esg } @str; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
|
385
|
0
|
|
|
|
|
|
return @str; |
386
|
|
|
|
|
|
|
} |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
################################################################################ |
389
|
|
|
|
|
|
|
# Convert a UTF-8 string or a list of strings to lower case # |
390
|
|
|
|
|
|
|
################################################################################ |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
sub utf2lc |
393
|
|
|
|
|
|
|
{ |
394
|
0
|
|
|
0
|
0
|
|
@_; # TODO |
395
|
|
|
|
|
|
|
} |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
################################################################################ |
398
|
|
|
|
|
|
|
# Convert a UTF-8 string or a list of strings to upper case # |
399
|
|
|
|
|
|
|
################################################################################ |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
sub utf2uc |
402
|
|
|
|
|
|
|
{ |
403
|
0
|
|
|
0
|
0
|
|
@_; # TODO |
404
|
|
|
|
|
|
|
} |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
1; |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
__END__ |