/[cvs]/nfo/perl/libs/Data/Mungle/Transform/Encode.pm
ViewVC logotype

Annotation of /nfo/perl/libs/Data/Mungle/Transform/Encode.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Fri Nov 29 04:49:20 2002 UTC (21 years, 7 months ago) by joko
Branch: MAIN
+ initial check-in

1 joko 1.1 ##############################################
2     #
3     # $Id: Common.pm,v 1.1 2002/10/10 03:26:00 cvsjoko Exp $
4     #
5     # $Log: Common.pm,v $
6     # Revision 1.1 2002/10/10 03:26:00 cvsjoko
7     # + new
8     #
9     ##############################################
10    
11    
12     package Data::Transform::Encode;
13    
14     use strict;
15     use warnings;
16    
17     require Exporter;
18     our @ISA = qw( Exporter );
19     our @EXPORT_OK = qw( &var2utf8 &var_utf2iso );
20    
21     use Unicode::String qw(utf8 latin1);
22    
23     sub var2utf8 {
24     my $vref = shift;
25     if (ref $vref eq 'HASH') {
26     foreach (keys %{$vref}) {
27     if ((ref $vref->{$_}) =~ m/ARRAY|HASH/) {
28     var2utf8($vref->{$_});
29     } else {
30     $vref->{$_} = scalar2utf8($vref->{$_});
31     }
32     }
33     } elsif (ref $vref eq 'ARRAY') {
34     foreach (@{$vref}) {
35     if (ref $_ ne 'SCALAR') {
36     var2utf8($_);
37     } else {
38     $_ = scalar2utf8($_);
39     }
40     }
41     }
42    
43     }
44    
45     sub scalar2utf8 {
46     my $scalar = shift;
47     if ($scalar) {
48     my $u = latin1($scalar);
49     return $u->utf8;
50     }
51     }
52    
53     sub var_utf2iso {
54     my $vref = shift;
55     if (ref $vref eq 'HASH') {
56     foreach (keys %{$vref}) {
57     if ((ref $vref->{$_}) =~ m/ARRAY|HASH/) {
58     var_utf2iso($vref->{$_});
59     } else {
60     $vref->{$_} = scalar2iso($vref->{$_});
61     }
62     }
63     } elsif (ref $vref eq 'ARRAY') {
64     foreach (@{$vref}) {
65     if (ref $_ ne 'SCALAR') {
66     var_utf2iso($_);
67     } else {
68     $_ = scalar2iso($_);
69     }
70     }
71     }
72    
73     }
74    
75     sub scalar2iso {
76     my $scalar = shift;
77     if ($scalar) {
78     my $u = utf8($scalar);
79     return $u->latin1;
80     }
81     }
82    
83     1;

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed