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-2026 Guido Flohr <guido.flohr@cantanea.com>,
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 <http://www.gnu.org/licenses/>.
20              
21             package Locale::RecodeData::_Encode;
22              
23 34     34   218 use strict;
  34         74  
  34         1404  
24 34     34   173 use integer;
  34         62  
  34         372  
25              
26 34     34   1161 use Encode;
  34         90  
  34         4026  
27              
28             require Locale::RecodeData;
29 34     34   259 use base qw (Locale::RecodeData);
  34         73  
  34         20352  
30              
31             sub _recode
32             {
33 34     34   220 use bytes;
  34         56  
  34         263  
34              
35 130543     130543   170694 my $retval;
36            
37 130543 100       265072 if ($_[0]->{_from} eq 'INTERNAL') {
    100          
38 61304         83752 $_[1] = pack "N*", @{$_[1]};
  61304         166319  
39 61304         214247 $retval = Encode::from_to ($_[1], 'UTF-32BE', $_[0]->{_to});
40             } elsif ($_[0]->{_to} eq 'INTERNAL') {
41 61243         185112 $retval = Encode::from_to ($_[1], $_[0]->{_from}, 'UTF-32BE');
42 61243 50       2526729 return unless defined $retval;
43 61243         139858 $_[1] = [ unpack "N*", $_[1] ];
44             } else {
45 7996         27394 $retval = Encode::from_to ($_[1], $_[0]->{_from}, $_[0]->{_to});
46             }
47            
48 130543 50       2888765 return unless defined $retval;
49 130543         241237 return 1;
50             }
51              
52             1;
53              
54             __END__
55              
56             =head1 NAME
57              
58             Locale::RecodeData::_Encode - Internal wrapper around Encode
59              
60             =head1 SYNOPSIS
61              
62             use Locale::RecodeData::_Encode;
63              
64             This module is internal to libintl. Do not use directly!
65              
66             =head1 DESCRIPTION
67              
68             This module converts text with the help of Encode(3). It is
69             tried first for conversions if libintl-perl detects the presence
70             of Encode.
71              
72             =head1 AUTHOR
73              
74             Copyright (C) 2002-2026 L<Guido Flohr|http://www.guido-flohr.net/>
75             (L<mailto:guido.flohr@cantanea.com>), all rights reserved. See the source
76             code for details!code for details!
77              
78             =head1 SEE ALSO
79              
80             Locale::Recode(3), Encode(3), perl(1)
81              
82             =cut
83             Local Variables:
84             mode: perl
85             perl-indent-level: 4
86             perl-continued-statement-offset: 4
87             perl-continued-brace-offset: 0
88             perl-brace-offset: -4
89             perl-brace-imaginary-offset: 0
90             perl-label-offset: -4
91             cperl-indent-level: 4
92             cperl-continued-statement-offset: 2
93             tab-width: 4
94             End: