line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Package Convert::Cyrillic |
2
|
|
|
|
|
|
|
# Version 1.02 |
3
|
|
|
|
|
|
|
# Part of "Cyrillic Software Suite" |
4
|
|
|
|
|
|
|
# Get docs and newest version from |
5
|
|
|
|
|
|
|
# http://www.neystadt.org/cyrillic/ |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Copyright (c) 1997-98, John Neystadt |
8
|
|
|
|
|
|
|
# You may install this script on your web site for free |
9
|
|
|
|
|
|
|
# To obtain permision for redistribution or any other usage |
10
|
|
|
|
|
|
|
# contact john@neystadt.org. |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# Drop me a line if you deploy this script on tyour site. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package Convert::Cyrillic; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$VERSION = "1.02"; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Convert::Cyrillic v1.02 - Routines for converting from one cyrillic charset to another. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
2216
|
use Unicode::Map8; |
|
1
|
|
|
|
|
7794
|
|
|
1
|
|
|
|
|
66
|
|
25
|
1
|
|
|
1
|
|
1499
|
use Unicode::String; |
|
1
|
|
|
|
|
12556
|
|
|
1
|
|
|
|
|
1378
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$UCase {'KOI'} = "\377"; |
28
|
|
|
|
|
|
|
$LCase {'KOI'} = "ţ"; |
29
|
|
|
|
|
|
|
$UCase {'WIN'} = "Ũ"; |
30
|
|
|
|
|
|
|
$LCase {'WIN'} = "\377"; |
31
|
|
|
|
|
|
|
$UCase {'DOS'} = ""; |
32
|
|
|
|
|
|
|
$LCase {'DOS'} = ""; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$tab{"KOI8"}="\377ţ"; |
35
|
|
|
|
|
|
|
$tab{"DOS"}=""; |
36
|
|
|
|
|
|
|
$tab{"ISO"}=""; |
37
|
|
|
|
|
|
|
$tab{"WIN"}="Ũ\377"; |
38
|
|
|
|
|
|
|
$tab{"VOL"}="ABVGDEZIJKLMNOPRSTUFXCW~Y'abvgdezijklmnoprstufxcw~y'\377"; |
39
|
|
|
|
|
|
|
$tab{"MAC"}="݆"; |
40
|
|
|
|
|
|
|
# 1234567890123456789012345678901234567890123456789012345678901234567890 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub cstocs { |
43
|
0
|
|
|
0
|
0
|
0
|
my ($Src, $Dst, $Buf) = @_; |
44
|
0
|
0
|
|
|
|
0
|
$Src = uc ($Src); $Src .= '8' if $Src eq 'KOI'; |
|
0
|
|
|
|
|
0
|
|
45
|
0
|
0
|
|
|
|
0
|
$Dst = uc ($Dst); $Dst .= '8' if $Dst eq 'KOI'; |
|
0
|
|
|
|
|
0
|
|
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
0
|
if ($Src eq 'UTF8') { |
48
|
0
|
|
|
|
|
0
|
my $map = Unicode::Map8->new("cp1251"); |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
$Buf = $map->to8 (Unicode::String::utf8 ($Buf)->ucs2); |
51
|
0
|
|
|
|
|
0
|
$Src = 'WIN'; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
0
|
if ($Dst eq 'UTF8') { |
55
|
0
|
|
|
|
|
0
|
eval "\$Buf =~ tr/$tab{$Src}/$tab{'WIN'}/"; |
56
|
0
|
|
|
|
|
0
|
my $map = Unicode::Map8->new("cp1251"); |
57
|
0
|
|
|
|
|
0
|
$Buf = $map->tou ($Buf)->utf8; |
58
|
|
|
|
|
|
|
} else { |
59
|
0
|
|
|
|
|
0
|
eval "\$Buf =~ tr/$tab{$Src}/$tab{$Dst}/"; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
0
|
if ($Dst eq 'VOL') { |
63
|
0
|
|
|
|
|
0
|
$Buf =~s//YO/go; $Buf =~s//ZH/go; $Buf =~s//CH/go; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
64
|
0
|
|
|
|
|
0
|
$Buf =~s//SH/go; $Buf =~s//E\'/go; $Buf =~s//YU/go; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
65
|
0
|
|
|
|
|
0
|
$Buf =~s//YA/go; $Buf =~s//yo/go; $Buf =~s//zh/go; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
66
|
0
|
|
|
|
|
0
|
$Buf =~s//ch/go; $Buf =~s//sh/go; $Buf =~s//e\'/go; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
67
|
0
|
|
|
|
|
0
|
$Buf =~s//yu/go; $Buf =~s/\377/ya/go; |
|
0
|
|
|
|
|
0
|
|
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
0
|
$Buf; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub toLower { |
73
|
3
|
|
|
3
|
0
|
3
|
my ($s, $Code) = @_; |
74
|
3
|
|
|
|
|
7
|
$Code = uc ($Code); |
75
|
3
|
100
|
66
|
|
|
18
|
if (exists $UCase {$Code} and exists $LCase {$Code}) {
|
76
|
2
|
|
|
|
|
131
|
eval ("\$s =~ tr/$UCase{$Code}/$LCase{$Code}/");
|
77
|
|
|
|
|
|
|
}
|
78
|
|
|
|
|
|
|
|
79
|
3
|
|
|
|
|
10
|
$s; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub toUpper { |
83
|
0
|
|
|
0
|
0
|
|
my ($s, $Code) = @_; |
84
|
0
|
|
|
|
|
|
$Code = uc ($Code); |
85
|
0
|
0
|
0
|
|
|
|
if (exists $UCase {$Code} and exists $LCase {$Code}) {
|
86
|
0
|
|
|
|
|
|
eval ("\$s =~ tr/$LCase{$Code}/$UCase{$Code}/");
|
87
|
|
|
|
|
|
|
}
|
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
$s; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |