File Coverage

blib/lib/Locale/RecodeData/_Encode.pm
Criterion Covered Total %
statement 26 26 100.0
branch 6 8 75.0
condition n/a
subroutine 6 6 100.0
pod n/a
total 38 40 95.0


line stmt bran cond sub pod time code
1             #! /bin/false
2             # vim: set autoindent shiftwidth=4 tabstop=4:
3              
4             # Interface to Encode.
5             # Copyright (C) 2002-2017 Guido Flohr ,
6             # all rights reserved.
7              
8             # This program is free software: you can redistribute it and/or modify
9             # it under the terms of the GNU General Public License as published by
10             # the Free Software Foundation; either version 3 of the License, or
11             # (at your option) any later version.
12              
13             # This program is distributed in the hope that it will be useful,
14             # but WITHOUT ANY WARRANTY; without even the implied warranty of
15             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16             # GNU General Public License for more details.
17              
18             # You should have received a copy of the GNU General Public License
19             # along with this program. If not, see .
20              
21             package Locale::RecodeData::_Encode;
22              
23 34     34   241 use strict;
  34         65  
  34         1072  
24 34     34   185 use integer;
  34         65  
  34         234  
25              
26 34     34   809 use Encode;
  34         80  
  34         3029  
27              
28             require Locale::RecodeData;
29 34     34   266 use base qw (Locale::RecodeData);
  34         80  
  34         16915  
30              
31             sub _recode
32             {
33 34     34   240 use bytes;
  34         82  
  34         180  
34              
35 130543     130543   161319 my $retval;
36            
37 130543 100       269405 if ($_[0]->{_from} eq 'INTERNAL') {
    100          
38 61304         80620 $_[1] = pack "N*", @{$_[1]};
  61304         181901  
39 61304         150949 $retval = Encode::from_to ($_[1], 'UTF-32BE', $_[0]->{_to});
40             } elsif ($_[0]->{_to} eq 'INTERNAL') {
41 61243         119819 $retval = Encode::from_to ($_[1], $_[0]->{_from}, 'UTF-32BE');
42 61243 50       4030957 return unless defined $retval;
43 61243         153010 $_[1] = [ unpack "N*", $_[1] ];
44             } else {
45 7996         15519 $retval = Encode::from_to ($_[1], $_[0]->{_from}, $_[0]->{_to});
46             }
47            
48 130543 50       4264204 return unless defined $retval;
49 130543         236530 return 1;
50             }
51              
52             1;
53              
54             __END__