Convert/Cyrillic.pm

filter: Statementstmt 40.6% 24 / 59 Branchbran 14.2% 2 / 14 Conditioncond 33.3% 2 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 3 totaltotal 35.1% 32 / 91 CC 10 SCAR 30.6
CC
10
Cov
35%
cstocs
42.0
toUpper
12.0
toLower
3.0
CRAP 21.4
« Convert/Cyrillic/Utils.pm ↑ Summary Lingua/DetectCharset.pm »
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 <http://www.neystadt.org/john/>
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 1 $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 ▶use Unicode::Map8;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Unicode::String;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 1 $UCase {'KOI'} = "áâ÷çäå³öúéêëìíîïðòóôõæèãþûý\377ùøüàñ";
28 1 $LCase {'KOI'} = "ÁÂ×ÇÄÅ£ÖÚÉÊËÌÍÎÏÐÒÓÔÕÆÈÃÞÛÝßÙØÜÀÑ";
29 1 $UCase {'WIN'} = "ÀÁÂÃÄŨÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞß";
30 1 $LCase {'WIN'} = "àáâãä叿çèéêëìíîïðñòóôõö÷øùúûüýþ\377";
31 1 $UCase {'DOS'} = "€‚ƒ„…ð†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ";
32 1 $LCase {'DOS'} = " ¡¢£¤¥ñ¦§¨©ª«¬­®¯àáâãäåæçèéêëìíîï";
33  
34 1 $tab{"KOI8"}="áâ÷çäå³öúéêëìíîïðòóôõæèãþûý\377ùøüàñÁÂ×ÇÄÅ£ÖÚÉÊËÌÍÎÏÐÒÓÔÕÆÈÃÞÛÝßÙØÜÀÑ";
35 1 $tab{"DOS"}="€‚ƒ„…ð†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥ñ¦§¨©ª«¬­®¯àáâãäåæçèéêëìíîï";
36 1 $tab{"ISO"}="°±²³´µ¡¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕñÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîï";
37 1 $tab{"WIN"}="ÀÁÂÃÄŨÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãä叿çèéêëìíîïðñòóôõö÷øùúûüýþ\377";
38 1 $tab{"VOL"}="ABVGDE¨ÆZIJKLMNOPRSTUFXCרW~Y'ÝÞßabvgde¸æzijklmnoprstufxc÷øw~y'ýþ\377";
39 1 $tab{"MAC"}="€‚ƒ„…݆‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸàáâãäåÞæçèéêëìíîïðñòóôõö÷øùúûüýþß";
40 # 1234567890123456789012345678901234567890123456789012345678901234567890
41  
42 0 ▶sub cstocs {
Subroutine cstocs: not called CC=6 SCAR=37.4
Pod undocumented
43 0 my ($Src, $Dst, $Buf) = @_;
44 0 ▶ $Src = uc ($Src); $Src .= '8' if $Src eq 'KOI';
Branch: 1 branch
BranchTrueFalseTotal
if $Src eq "KOI" 0 0 0
45 0 ▶ $Dst = uc ($Dst); $Dst .= '8' if $Dst eq 'KOI';
Branch: 1 branch
BranchTrueFalseTotal
if $Dst eq "KOI" 0 0 0
46  
47 0 ▶ if ($Src eq 'UTF8') {
Branch: 1 branch
BranchTrueFalseTotal
if ($Src eq "UTF8") 0 0 0
48 0 my $map = Unicode::Map8->new("cp1251");
49
50 0 $Buf = $map->to8 (Unicode::String::utf8 ($Buf)->ucs2);
51 0 $Src = 'WIN';
52 }
53  
54 0 ▶ if ($Dst eq 'UTF8') {
Branch: 1 branch
BranchTrueFalseTotal
if ($Dst eq 'UTF8') { } 0 0 0
55 0 eval "\$Buf =~ tr/$tab{$Src}/$tab{'WIN'}/";
56 0 my $map = Unicode::Map8->new("cp1251");
57 0 $Buf = $map->tou ($Buf)->utf8;
58 } else {
59 0 eval "\$Buf =~ tr/$tab{$Src}/$tab{$Dst}/";
60 }
61  
62 0 ▶ if ($Dst eq 'VOL') {
Branch: 1 branch
BranchTrueFalseTotal
if ($Dst eq "VOL") 0 0 0
63 0 $Buf =~s/¨/YO/go; $Buf =~s/Æ/ZH/go; $Buf =~s/×/CH/go;
64 0 $Buf =~s/Ø/SH/go; $Buf =~s/Ý/E\'/go; $Buf =~s/Þ/YU/go;
65 0 $Buf =~s/ß/YA/go; $Buf =~s/¸/yo/go; $Buf =~s/æ/zh/go;
66 0 $Buf =~s/÷/ch/go; $Buf =~s/ø/sh/go; $Buf =~s/ý/e\'/go;
67 0 $Buf =~s/þ/yu/go; $Buf =~s/\377/ya/go;
68 }
69 0 $Buf;
70 }
71  
72 3 ▶sub toLower {
Subroutine toLower: called CC=3 SCAR=11.0
Pod undocumented
73 3 my ($s, $Code) = @_;
74 3 $Code = uc ($Code);
75 3 ▶ if (exists $UCase {$Code} and exists $LCase {$Code}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $UCase{$Code} and exists $LCase{$Code}) 2 1 3
Condition66%2/3
exists $UCase{$Code} and exists $LCase{$Code}
!ll&&!rl&&r
102
MC/DC50%1/2
exists $UCase{$Code} and exists $LCase{$Code}
exists $UCase{$Code} exists $LCase{$Code}
Truth table66%2/3
A and B
A= exists $UCase{$Code}B= exists $LCase{$Code}
ABresult
0X0
100
111
76 2 eval ("\$s =~ tr/$UCase{$Code}/$LCase{$Code}/");
77 }
78  
79 3 $s;
80 }
81  
82 0 ▶sub toUpper {
Subroutine toUpper: not called CC=3 SCAR=24.8
Pod undocumented
83 0 my ($s, $Code) = @_;
84 0 $Code = uc ($Code);
85 0 ▶ if (exists $UCase {$Code} and exists $LCase {$Code}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $UCase{$Code} and exists $LCase{$Code}) 0 0 0
Condition0%0/3
exists $UCase{$Code} and exists $LCase{$Code}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $UCase{$Code} and exists $LCase{$Code}
exists $UCase{$Code} exists $LCase{$Code}
Truth table0%0/3
A and B
A= exists $UCase{$Code}B= exists $LCase{$Code}
ABresult
0X0
100
111
86 0 eval ("\$s =~ tr/$LCase{$Code}/$UCase{$Code}/");
87 }
88  
89 0 $s;
90 }
91  
92 __END__
« Convert/Cyrillic/Utils.pm ↑ Summary Lingua/DetectCharset.pm »