line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Lingua/RU/Jcuken.pm |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Copyright (c) 2006-2008 Serguei Trouchelle. All rights reserved. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it |
6
|
|
|
|
|
|
|
# under the same terms as Perl itself. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# History: |
9
|
|
|
|
|
|
|
# 1.04 2008/02/26 use Encode instead of Text::Iconv |
10
|
|
|
|
|
|
|
# 1.03 2007/02/04 Quality update (Test::Pod, Test::Pod::Coverage) |
11
|
|
|
|
|
|
|
# 1.02 2006/11/15 Fixed problem with undefined encoding in qwe2jcu |
12
|
|
|
|
|
|
|
# 1.01 2006/11/15 Initial revision |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Lingua::RU::Jcuken -- Conversion between QWERTY and JCUKEN keys in Russian |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Lingua::RU::Jcuken qw/ jcu2qwe qwe2jcu /; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
print qwe2jcu('qwerty', 'koi8-r'); # prints "jcuken" in koi8-r |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Lingua::RU::Jcuken can be used for conversion between two layouts on Russian keyboards. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
package Lingua::RU::Jcuken; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
require Exporter; |
35
|
5
|
|
|
5
|
|
37254
|
use Config; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
284
|
|
36
|
|
|
|
|
|
|
|
37
|
5
|
|
|
5
|
|
31
|
use strict; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
151
|
|
38
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
21
|
|
|
5
|
|
|
|
|
154
|
|
39
|
|
|
|
|
|
|
|
40
|
5
|
|
|
5
|
|
19873
|
use Encode; |
|
5
|
|
|
|
|
64500
|
|
|
5
|
|
|
|
|
2638
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
our @EXPORT = qw/ /; |
43
|
|
|
|
|
|
|
our @EXPORT_OK = qw/ jcu2qwe qwe2jcu /; |
44
|
|
|
|
|
|
|
our %EXPORT_TAGS = qw / /; |
45
|
|
|
|
|
|
|
our @ISA = qw/Exporter/; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
our $VERSION = "1.04"; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $table = q!1 1 |
50
|
|
|
|
|
|
|
q é |
51
|
|
|
|
|
|
|
w ö |
52
|
|
|
|
|
|
|
e ó |
53
|
|
|
|
|
|
|
r ê |
54
|
|
|
|
|
|
|
t å |
55
|
|
|
|
|
|
|
y í |
56
|
|
|
|
|
|
|
u ã |
57
|
|
|
|
|
|
|
i ø |
58
|
|
|
|
|
|
|
o ù |
59
|
|
|
|
|
|
|
p ç |
60
|
|
|
|
|
|
|
[ õ |
61
|
|
|
|
|
|
|
] ú |
62
|
|
|
|
|
|
|
a ô |
63
|
|
|
|
|
|
|
s û |
64
|
|
|
|
|
|
|
d â |
65
|
|
|
|
|
|
|
f à |
66
|
|
|
|
|
|
|
g ï |
67
|
|
|
|
|
|
|
h ð |
68
|
|
|
|
|
|
|
j î |
69
|
|
|
|
|
|
|
k ë |
70
|
|
|
|
|
|
|
l ä |
71
|
|
|
|
|
|
|
; æ |
72
|
|
|
|
|
|
|
' ý |
73
|
|
|
|
|
|
|
z ÿ |
74
|
|
|
|
|
|
|
x ÷ |
75
|
|
|
|
|
|
|
c ñ |
76
|
|
|
|
|
|
|
v ì |
77
|
|
|
|
|
|
|
b è |
78
|
|
|
|
|
|
|
n ò |
79
|
|
|
|
|
|
|
m ü |
80
|
|
|
|
|
|
|
, á |
81
|
|
|
|
|
|
|
. þ |
82
|
|
|
|
|
|
|
/ . |
83
|
|
|
|
|
|
|
` ¸ |
84
|
|
|
|
|
|
|
Q É |
85
|
|
|
|
|
|
|
W Ö |
86
|
|
|
|
|
|
|
E Ó |
87
|
|
|
|
|
|
|
R Ê |
88
|
|
|
|
|
|
|
T Å |
89
|
|
|
|
|
|
|
Y Í |
90
|
|
|
|
|
|
|
U Ã |
91
|
|
|
|
|
|
|
I Ø |
92
|
|
|
|
|
|
|
O Ù |
93
|
|
|
|
|
|
|
P Ç |
94
|
|
|
|
|
|
|
{ Õ |
95
|
|
|
|
|
|
|
} Ú |
96
|
|
|
|
|
|
|
A Ô |
97
|
|
|
|
|
|
|
S Û |
98
|
|
|
|
|
|
|
D Â |
99
|
|
|
|
|
|
|
F À |
100
|
|
|
|
|
|
|
G Ï |
101
|
|
|
|
|
|
|
H Ð |
102
|
|
|
|
|
|
|
J Î |
103
|
|
|
|
|
|
|
K Ë |
104
|
|
|
|
|
|
|
L Ä |
105
|
|
|
|
|
|
|
: Æ |
106
|
|
|
|
|
|
|
" Ý |
107
|
|
|
|
|
|
|
Z ß |
108
|
|
|
|
|
|
|
X × |
109
|
|
|
|
|
|
|
C Ñ |
110
|
|
|
|
|
|
|
V Ì |
111
|
|
|
|
|
|
|
B È |
112
|
|
|
|
|
|
|
N Ò |
113
|
|
|
|
|
|
|
M Ü |
114
|
|
|
|
|
|
|
< Á |
115
|
|
|
|
|
|
|
> Þ |
116
|
|
|
|
|
|
|
? . |
117
|
|
|
|
|
|
|
~ ¨ |
118
|
|
|
|
|
|
|
2 2!; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
our %qwe2jcu = split /\s+/, $table; |
121
|
|
|
|
|
|
|
our %jcu2qwe = reverse split /\s+/, $table; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 jcu2qwe ( $string, [ $encoding ]) |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This method converts $string from Jcuken to Qwerty. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Optional $encoding parameter allows to specify $string's encoding (default is 'windows-1251') |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub jcu2qwe { |
132
|
4
|
|
|
4
|
1
|
21
|
my $val = shift; |
133
|
4
|
|
|
|
|
7
|
my $enc = shift; |
134
|
4
|
100
|
|
|
|
23
|
Encode::from_to($val, $enc, 'windows-1251') if $enc; |
135
|
4
|
|
|
|
|
5695
|
my $res = ''; |
136
|
4
|
|
|
|
|
23
|
foreach (split //, $val) { |
137
|
24
|
100
|
|
|
|
66
|
$_ = $jcu2qwe{$_} if $jcu2qwe{$_}; |
138
|
24
|
|
|
|
|
33
|
$res .= $_; |
139
|
|
|
|
|
|
|
} |
140
|
4
|
|
|
|
|
28
|
return $res; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 qwe2jcu ( $string, [ $encoding ]) |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This method converts $string from Qwerty to Jcuken. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Optional $encoding parameter allows to specify result encoding (default is 'windows-1251'). |
148
|
|
|
|
|
|
|
It is also used as $string encoding if you have cyrillic in it. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub qwe2jcu { |
153
|
4
|
|
|
4
|
1
|
22
|
my $val = shift; |
154
|
4
|
|
|
|
|
8
|
my $enc = shift; |
155
|
4
|
100
|
|
|
|
19
|
Encode::from_to($val, $enc, 'windows-1251') if $enc; |
156
|
4
|
100
|
|
|
|
4225
|
$enc = 'windows-1251' unless $enc; |
157
|
4
|
|
|
|
|
9
|
my $res = ''; |
158
|
4
|
|
|
|
|
19
|
foreach (split //, $val) { |
159
|
24
|
100
|
|
|
|
82
|
$_ = $qwe2jcu{$_} if $qwe2jcu{$_}; |
160
|
24
|
|
|
|
|
58
|
Encode::from_to($_, 'windows-1251', $enc); |
161
|
24
|
|
|
|
|
4308
|
$res .= $_; |
162
|
|
|
|
|
|
|
} |
163
|
4
|
|
|
|
|
27
|
return $res; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
1; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 AUTHORS |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Serguei Trouchelle EFE |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 COPYRIGHT |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Copyright (c) 2006-2008 Serguei Trouchelle. All rights reserved. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
177
|
|
|
|
|
|
|
under the same terms as Perl itself. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=cut |
180
|
|
|
|
|
|
|
|