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   227 use strict;
  34         64  
  34         1054  
24 34     34   182 use integer;
  34         64  
  34         207  
25              
26 34     34   713 use Encode;
  34         86  
  34         2763  
27              
28             require Locale::RecodeData;
29 34     34   232 use base qw (Locale::RecodeData);
  34         74  
  34         15973  
30              
31             sub _recode
32             {
33 34     34   222 use bytes;
  34         70  
  34         167  
34              
35 130543     130543   163145 my $retval;
36            
37 130543 100       261930 if ($_[0]->{_from} eq 'INTERNAL') {
    100          
38 61304         80732 $_[1] = pack "N*", @{$_[1]};
  61304         166835  
39 61304         152854 $retval = Encode::from_to ($_[1], 'UTF-32BE', $_[0]->{_to});
40             } elsif ($_[0]->{_to} eq 'INTERNAL') {
41 61243         121692 $retval = Encode::from_to ($_[1], $_[0]->{_from}, 'UTF-32BE');
42 61243 50       4004411 return unless defined $retval;
43 61243         158846 $_[1] = [ unpack "N*", $_[1] ];
44             } else {
45 7996         15212 $retval = Encode::from_to ($_[1], $_[0]->{_from}, $_[0]->{_to});
46             }
47            
48 130543 50       4208832 return unless defined $retval;
49 130543         238831 return 1;
50             }
51              
52             1;
53              
54             __END__