blib/lib/Convert/EastAsianWidth.pm

filter: Statementstmt 92.8% 26 / 28 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 81.4% 35 / 43 CC 5 SCAR 8.9
CC
5
Cov
83%
to_fullwidth
3.1
to_halfwidth
3.1
BEGIN
1.0
CRAP 2.4
↑ Summary
1 package Convert::EastAsianWidth;
2  
3 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '1.02';
8 1 our @ISA = 'Exporter';
9 1 our @EXPORT = qw(to_fullwidth to_halfwidth);
10  
11 1 ▶sub to_fullwidth {
Subroutine to_fullwidth: called CC=3 SCAR=11.4
Pod undocumented
12 1 my $text;
13 1 my $enc = $_[1];
14  
15 1 ▶ if ($enc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($enc) { } 1 0 1
16 1 require Encode;
17 1 $text = Encode::decode($enc => $_[0]);
18 }
19 else {
20 0 $text = $_[0];
21 }
22  
23 1 $text =~ tr/ -~/\x{3000}\x{FF01}-\x{FF5E}/;
24  
25 1 ▶ return ( $enc ? Encode::encode($enc => $text) : $text );
Branch: 1 branch
BranchTrueFalseTotal
$enc ? : 1 0 1
26 }
27  
28 1 ▶sub to_halfwidth {
Subroutine to_halfwidth: called CC=3 SCAR=11.4
Pod undocumented
29 1 my $text;
30 1 my $enc = $_[1];
31  
32 1 ▶ if ($enc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($enc) { } 1 0 1
33 1 require Encode;
34 1 $text = Encode::decode($enc => $_[0]);
35 }
36 else {
37 0 $text = $_[0];
38 }
39  
40 1 $text =~ tr/\x{3000}\x{FF01}-\x{FF5E}/ -~/;
41  
42 1 ▶ return ( $enc ? Encode::encode($enc => $text) : $text );
Branch: 1 branch
BranchTrueFalseTotal
$enc ? : 1 0 1
43 }
44 1 1;
45  
46 __END__
↑ Summary