1#! /bin/false
2# vim: set autoindent shiftwidth=4 tabstop=4:
3# $Id: _Encode.pm,v 1.1 2009/11/01 19:00:13 pertusus Exp $
4
5# Interface to Encode.
6# Copyright (C) 2002-2009 Guido Flohr <guido@imperia.net>,
7# all rights reserved.
8
9# This program is free software; you can redistribute it and/or modify it
10# under the terms of the GNU Library General Public License as published
11# by the Free Software Foundation; either version 2, or (at your option)
12# any later version.
13
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17# Library General Public License for more details.
18
19# You should have received a copy of the GNU Library General Public
20# License along with this program; if not, write to the Free Software
21# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22# USA.
23
24package Locale::RecodeData::_Encode;
25
26use strict;
27use integer;
28
29use Encode;
30
31require Locale::RecodeData;
32use base qw (Locale::RecodeData);
33
34sub _recode
35{
36	use bytes;
37
38	my $retval;
39
40	if ($_[0]->{_from} eq 'INTERNAL') {
41		$_[1] = pack "N*", @{$_[1]};
42		$retval = Encode::from_to ($_[1], 'UTF-32BE', $_[0]->{_to});
43	} elsif ($_[0]->{_to} eq 'INTERNAL') {
44		$retval = Encode::from_to ($_[1], $_[0]->{_from}, 'UTF-32BE');
45		return unless defined $retval;
46		$_[1] = [ unpack "N*", $_[1] ];
47	} else {
48		$retval = Encode::from_to ($_[1], $_[0]->{_from}, $_[0]->{_to});
49	}
50
51	return unless defined $retval;
52	return 1;
53}
54
551;
56
57__END__
58
59=head1 NAME
60
61Locale::RecodeData::_Encode - Internal wrapper around Encode
62
63=head1 SYNOPSIS
64
65use Locale::RecodeData::_Encode;
66
67This module is internal to libintl.  Do not use directly!
68
69=head1 DESCRIPTION
70
71This module converts text with the help of Encode(3).  It is
72tried first for conversions if libintl-perl detects the presence
73of Encode.
74
75=head1 AUTHOR
76
77Copyright (C) 2002-2009, Guido Flohr E<lt>guido@imperia.netE<gt>, all
78rights reserved.  See the source code for details.
79
80This software is contributed to the Perl community by Imperia
81(L<http://www.imperia.net/>).
82
83=head1 SEE ALSO
84
85Locale::Recode(3), Encode(3), perl(1)
86
87=cut
88Local Variables:
89mode: perl
90perl-indent-level: 4
91perl-continued-statement-offset: 4
92perl-continued-brace-offset: 0
93perl-brace-offset: -4
94perl-brace-imaginary-offset: 0
95perl-label-offset: -4
96cperl-indent-level: 4
97cperl-continued-statement-offset: 2
98tab-width: 4
99End:
100=cut
101