--- trunk/lib/WebPAC/Output/Estraier.pm 2005/11/20 20:13:39 74 +++ trunk/lib/WebPAC/Output/Estraier.pm 2005/11/20 20:32:41 75 @@ -91,11 +91,13 @@ my $encoding = $self->{'encoding'} || 'ISO-8859-2'; $log->info("using encoding $encoding"); - my $iconv = new Text::Iconv('iso-8859-2', 'utf-8'); + $self->{'iconv'} = new Text::Iconv($encoding, 'UTF-8') or + $log->die("can't create conversion from $encoding to UTF-8"); $self ? return $self : return undef; } + =head2 add Adds one entry to database. @@ -138,7 +140,7 @@ $log->debug("creating $uri"); my $doc = HyperEstraier::Document->new; - $doc->add_attr('@uri', $uri); + $doc->add_attr('@uri', $self->{'iconv'}->convert($uri) ); $log->debug("ds = ", sub { Dumper($args->{'ds'}) } ); @@ -157,12 +159,19 @@ $log->logconfess("no values for $tag/$type") unless ($vals); - $doc->add_attr($tag, $vals); - $doc->add_hidden_text($vals); + $vals = $self->{'iconv'}->convert( $vals ) or + $log->die("can't convert '$vals' to UTF-8"); + + $doc->add_attr( $tag, $vals ); + $doc->add_hidden_text( $vals ); } my $text = $args->{'text'}; - $doc->add_text( $text ) if ( $text ); + if ( $text ) { + $text = $self->{'iconv'}->convert( $text ) or + $log->die("can't convert '$text' to UTF-8"); + $doc->add_text( $text ); + } $log->debug("adding ", sub { $doc->dump_draft } ); $self->{'db'}->put_doc($doc) || $log->die("can't add document $uri to index");