blib/lib/Encode/Unicode.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 100% 52 / 52 CC 2 SCAR 2.5
CC
2
Cov
100%
renew
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« blib/lib/Encode/KR/2022_KR.pm ↑ Summary Encode.xs »
1 package Encode::Unicode;
2  
3 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 12 our $VERSION = '2.21';
7  
8 12 ▶use XSLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 12 XSLoader::load( __PACKAGE__, $VERSION );
10  
11 #
12 # Object Generator 8 transcoders all at once!
13 #
14  
15 12 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 12 our %BOM_Unknown = map { $_ => 1 } qw(UTF-16 UTF-32);
18  
19 12 for my $name (
20 qw(UTF-16 UTF-16BE UTF-16LE
21 UTF-32 UTF-32BE UTF-32LE
22 UCS-2BE UCS-2LE)
23 )
24 {
25 96 my ( $size, $endian, $ucs2, $mask );
26 96 $name =~ /^(\w+)-(\d+)(\w*)$/o;
27 96 ▶ if ( $ucs2 = ( $1 eq 'UCS' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucs2 = $1 eq 'UCS') { } 24 72 96
28 24 $size = 2;
29 }
30 else {
31 72 $size = $2 / 8;
32 }
33 96 ▶ $endian = ( $3 eq 'BE' ) ? 'n' : ( $3 eq 'LE' ) ? 'v' : '';
Branch: 2 branches
BranchTrueFalseTotal
$3 eq 'BE' ? : 36 60 96
$3 eq 'LE' ? : 36 24 60
34 96 ▶ $size == 4 and $endian = uc($endian);
Branch: 1 branch
BranchTrueFalseTotal
$size == 4 and $endian = uc $endian 36 60 96
35  
36 96 my $obj = bless {
37 Name => $name,
38 size => $size,
39 endian => $endian,
40 ucs2 => $ucs2,
41 } => __PACKAGE__;
42 96 Encode::define_encoding($obj, $name);
43 }
44  
45 12 ▶use parent qw(Encode::Encoding);
Subroutine BEGIN: called CC=1 SCAR=0.0
46  
47 14 ▶sub renew {
Subroutine renew: called CC=2 SCAR=6.9
Pod documented
48 14 my $self = shift;
49 14 ▶ $BOM_Unknown{ $self->name } or return $self;
Branch: 1 branch
BranchTrueFalseTotal
$Encode::Unicode::BOM_Unknown{$self->name} or return $self 6 8 14
50 6 my $clone = bless {%$self} => ref($self);
51 6 $clone->{renewed}++; # so the caller knows it is renewed.
52 6 return $clone;
53 }
54  
55 12 1;
56 __END__
« blib/lib/Encode/KR/2022_KR.pm ↑ Summary Encode.xs »