blib/lib/Encode/Detect.pm

filter: Statementstmt 96.0% 24 / 25 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 85.7% 6 / 7 Podpod 100% 2 / 2 totaltotal 81.8% 36 / 44 CC 5 SCAR 11.6
CC
5
Cov
85%
decode
5.6
perlio_ok
2.0
BEGIN
1.0
CRAP 3.2
↑ Summary src/CharDistribution.h »
1 package Encode::Detect;
2  
3 # * ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 #
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
10 #
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
14 # License.
15 #
16 # The Original Code is Encode::Detect wrapper
17 #
18 # The Initial Developer of the Original Code is
19 # Proofpoint, Inc.
20 # Portions created by the Initial Developer are Copyright (C) 2005
21 # the Initial Developer. All Rights Reserved.
22 #
23 # Contributor(s):
24 #
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 2 or later (the "GPL"), or
27 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
36 #
37 # ***** END LICENSE BLOCK *****
38  
39 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 1 ▶use base qw(Encode::Encoding);
Subroutine BEGIN: called CC=1 SCAR=0.0
42 1 ▶use Encode qw(find_encoding);
Subroutine BEGIN: called CC=1 SCAR=0.0
43 1 ▶use Encode::Detect::Detector;
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 1 __PACKAGE__->Define(qw(Detect));
46  
47 1 our $VERSION = "1.01";
48  
49 0 ▶sub perlio_ok { 0 }
Subroutine perlio_ok: not called CC=1 SCAR=6.9
Pod documented
50  
51 2 ▶sub decode ($$;$) {
Subroutine decode: called CC=5 SCAR=17.2
Pod documented
52 2 my ($self, $octets, $check) = @_;
53 2 ▶ my $charset = detect($octets) || 'Windows-1252';
Condition50%1/2
&detect($octets) || 'Windows-1252'
l!l
20
MC/DC0%0/1
&detect($octets) || 'Windows-1252'
&detect($octets)
Truth table50%1/2
A
A= &detect($octets)
Aresult
11
00
54 2 ▶ my $e = find_encoding($charset) or die "Unknown encoding: $charset";
Branch: 1 branch
BranchTrueFalseTotal
my $e = &find_encoding($charset) or die "Unknown encoding: $charset" 2 0 2
55 2 ▶ my $decoded = $e->decode($octets, $check || 0);
Condition50%1/2
$check || 0
l!l
02
MC/DC0%0/1
$check || 0
$check
Truth table50%1/2
A
A= $check
Aresult
11
00
56 2 ▶ $_[1] = $octets if $check;
Branch: 1 branch
BranchTrueFalseTotal
if $check 0 2 2
57 2 return $decoded;
58 }
59  
60 1 1;
61  
62 __END__
↑ Summary src/CharDistribution.h »