use strict;
use Search::Estraier;
-use Text::Iconv;
+use Encode qw/from_to/;
use Data::Dumper;
=head1 NAME
=head1 VERSION
-Version 0.06
+Version 0.07
=cut
-our $VERSION = '0.06';
+our $VERSION = '0.07';
=head1 SYNOPSIS
$self->{db}->set_url($self->{'url'});
$self->{db}->set_auth($self->{'user'}, $self->{'passwd'});
- my $encoding = $self->{'encoding'} || 'ISO-8859-2';
- $log->info("using encoding $encoding");
-
- $self->{'iconv'} = new Text::Iconv('UTF-8', $encoding) or
- $log->die("can't create conversion from UTF-8 to $encoding");
+ $self->{'encoding'} ||= 'ISO-8859-2';
+ $log->info("using encoding ",$self->{encoding});
$self ? return $self : return undef;
}
if ( ref($args->{add_attr}) eq 'ARRAY' ) {
$log->debug("adding search attributes: " . join(", ", @{ $args->{add_attr} }) );
map {
- $cond->add_attr( $self->{iconv}->convert( $_ ) );
+ $cond->add_attr( $self->convert( $_ ) );
$log->debug(" + $_");
} @{ $args->{add_attr} };
};
- $cond->set_phrase( $self->{iconv}->convert($q) ) if ($q);
+ $cond->set_phrase( $self->convert($q) ) if ($q);
$cond->set_options( $args->{options} ) if ($args->{options});
$cond->set_order( $args->{order} ) if ($args->{order});
foreach my $attr (@{ $args->{get_attr} }) {
my $val = $doc->attr( $attr );
#$log->debug("attr $attr = ", $val || 'undef');
- $hash->{$attr} = $self->{iconv}->convert( $val ) if (defined($val));
+ $hash->{$attr} = $self->convert( $val ) if (defined($val));
}
if ($hash) {
}
}
+=head2 convert
+
+convert internal encoding to UTF-8
+
+ my $utf8 = $self->convert( $text );
+
+=cut
+
+sub convert {
+ my $self = shift;
+
+ my $text = shift || return;
+
+ from_to($text, $self->{encoding}, 'UTF-8');
+ return $text;
+}
+
+
=head2 _get_logger
For compatibility with same method from L<WebPAC::Common>, but without