/[webpac2]/Webpacus/lib/Webpacus/Model/Databases.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /Webpacus/lib/Webpacus/Model/Databases.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 348 by dpavlin, Tue Dec 27 21:36:42 2005 UTC revision 349 by dpavlin, Sat Jan 7 17:34:21 2006 UTC
# Line 3  package Webpacus::Model::Databases; Line 3  package Webpacus::Model::Databases;
3  use strict;  use strict;
4  use warnings;  use warnings;
5  use base 'Catalyst::Model';  use base 'Catalyst::Model';
6  use Text::Iconv;  use Encode qw/decode/;
7    
8  =head1 NAME  =head1 NAME
9    
# Line 30  sub new { Line 30  sub new {
30                  $c->log->fail("didn't find databases in config");                  $c->log->fail("didn't find databases in config");
31          $self->{log} = $c->log;          $self->{log} = $c->log;
32    
33          my $from = $c->config->{config_encoding};          $c->log->debug("using config encoding ", $self->config->{config_encoding});
         my $to = $c->config->{catalyst_encoding};  
   
         $self->{iconv} = new Text::Iconv($from, $to) if ($from && $to);  
34    
35          return $self;          return $self;
36  }  }
37    
38  =head1 convert  =head1 convert
39    
40  Convert encodings from C<config_encoding> to C<catalyst_encoding>  Convert encodings from C<config_encoding>
41    
42    my $utf8 = $self->convert('foobar');    my $utf8 = $self->convert('foobar');
43    
# Line 49  Convert encodings from C<config_encoding Line 46  Convert encodings from C<config_encoding
46  sub convert {  sub convert {
47          my $self = shift;          my $self = shift;
48          my $val = shift || return;          my $val = shift || return;
49          return $val unless ($self->{iconv});          my $encoding = $self->config->{config_encoding} || return $val;
50            return decode($encoding, $val);
         return $self->{iconv}->convert($val);  
51  }  }
52    
53  =head1 list_inputs  =head1 list_inputs

Legend:
Removed from v.348  
changed lines
  Added in v.349

  ViewVC Help
Powered by ViewVC 1.1.26