blib/lib/Encode/IBM/835SOSI.pm

filter: Statementstmt 47.0% 16 / 34 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 66.6% 4 / 6 Podpod 100% 2 / 2 totaltotal 32.3% 22 / 68 SCAR 35.8
CC
9
Cov
31%
decode
30.0
encode
30.0
BEGIN
1.0
CRAP 35.9
« blib/lib/Encode/IBM/835SOSI/TSGH.pm ↑ Summary blib/lib/Encode/IBM/939SOSI.pm »
1 package Encode::IBM::835SOSI;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 $VERSION = '1.01';
6  
7 1 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use base qw(Encode::Encoding);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 __PACKAGE__->Define('ibm-835-sosi');
11  
12 1 my $base37;
13 my $base835;
14  
15 sub decode
16 {
17 0 ▶ my ($obj,$str,$chk) = @_;
Subroutine decode: not called CC=5 SCAR=34.0
Pod documented
18  
19 0 ▶ $base37 ||= Encode::find_encoding('cp37');
Condition0%0/3
$base37 ||= &Encode::find_encoding("cp37")
l!l&&r!l&&!r
000
MC/DC0%0/2
$base37 ||= &Encode::find_encoding("cp37")
$base37 &Encode::find_encoding("cp37")
Truth table0%0/3
A ||= B
A= $base37B= &Encode::find_encoding("cp37")
ABresult
1X1
011
000
20 0 ▶ $base835 ||= Encode::find_encoding('ibm-835');
Condition0%0/3
$base835 ||= &Encode::find_encoding("ibm-835")
l!l&&r!l&&!r
000
MC/DC0%0/2
$base835 ||= &Encode::find_encoding("ibm-835")
$base835 &Encode::find_encoding("ibm-835")
Truth table0%0/3
A ||= B
A= $base835B= &Encode::find_encoding("ibm-835")
ABresult
1X1
011
000
21  
22 0 my $out;
23 0 foreach my $chunk (split(/\x0E([^\x0F]*\x0F)/, $str)) {
24 0 ▶ if ($chunk =~ /\x0F\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chunk =~ /\x0F\z/) { } 0 0 0
25 0 chop $chunk;
26 0 $out .= $base835->decode($chunk);
27 }
28 else {
29 0 $out .= $base37->decode($chunk);
30 }
31 }
32 0 return $out;
33 }
34  
35 sub encode
36 {
37 0 ▶ my ($obj,$str,$chk) = @_;
Subroutine encode: not called CC=5 SCAR=34.0
Pod documented
38  
39 0 ▶ $base37 ||= Encode::find_encoding('cp37');
Condition0%0/3
$base37 ||= &Encode::find_encoding("cp37")
l!l&&r!l&&!r
000
MC/DC0%0/2
$base37 ||= &Encode::find_encoding("cp37")
$base37 &Encode::find_encoding("cp37")
Truth table0%0/3
A ||= B
A= $base37B= &Encode::find_encoding("cp37")
ABresult
1X1
011
000
40 0 ▶ $base835 ||= Encode::find_encoding('ibm-835');
Condition0%0/3
$base835 ||= &Encode::find_encoding("ibm-835")
l!l&&r!l&&!r
000
MC/DC0%0/2
$base835 ||= &Encode::find_encoding("ibm-835")
$base835 &Encode::find_encoding("ibm-835")
Truth table0%0/3
A ||= B
A= $base835B= &Encode::find_encoding("ibm-835")
ABresult
1X1
011
000
41  
42 0 ▶ if ($str =~ s/^([\x00-\xff]+)//) {
Branch: 2 branches
BranchTrueFalseTotal
if ($str =~ s/^([\x00-\xff]+)//) { } 0 0 0
elsif ($str =~ s/^([^\x00-\xff]+)//) { } 0 0 0
43 # english
44 0 my $sub = $1;
45 0 return $base37->encode($sub) . $obj->encode($str, $chk);
46 }
47 elsif ($str =~ s/^([^\x00-\xff]+)//) {
48 # chinese - shift in + shift out
49 0 my $sub = $1;
50 0 return "\x0E".$base835->encode($sub)."\x0F".$obj->encode($str, $chk);
51 }
52 }
53  
54 1 1;
55 __END__
« blib/lib/Encode/IBM/835SOSI/TSGH.pm ↑ Summary blib/lib/Encode/IBM/939SOSI.pm »