use base qw/WebPAC::Common/;
use Text::CSV;
+use Encode;
use Data::Dump qw/dump/;
=head1 NAME
=cut
-our $VERSION = '0.01';
+our $VERSION = '0.02';
=head1 FUNCTIONS
my $log = $self->_get_logger();
- open( my $fh, '<:encoding(utf-8)', $arg->{path} ) || $log->logconfess("can't open $arg->{path}: $!");
+ open( my $fh, '<:raw', $arg->{path} ) || $log->logconfess("can't open $arg->{path}: $!");
my $csv = Text::CSV->new({ binary => 1 });
$rec->{'000'} = [ ++$self->{size} ];
my $col = 'A';
- $rec->{ $col++ } = $_ foreach @$line;
+ $rec->{ $col++ } = Encode::decode_utf8( $_ ) foreach @$line;
push @{ $self->{_rec} }, $rec;
=cut
sub fetch_rec {
- my $self = shift;
-
- my ( $mfn, $filter_coderef ) = @_;
+ my ( $self, $mfn, $filter_coderef ) = @_;
return $self->{_rec}->[$mfn-1];
}
#!/usr/bin/perl -w
use strict;
-use blib;
+use lib 'lib';
-use Test::More tests => 27;
+use Test::More tests => 63;
BEGIN {
use_ok( 'WebPAC::Test' );
use_ok( 'WebPAC::Input' );
+use_ok( 'Encode' );
+use_ok( 'Devel::Peek' );
}
my $module = 'WebPAC::Input::CSV';
path => "$abs_path/data/records-utf8.csv"
), "open");
ok(my $size = $input->size, "size");
-cmp_ok( $size, '==', 7, 'size ok' );
+cmp_ok( $size, '==', 11, 'size ok' );
foreach my $mfn ( 1 ... $size ) {
my $rec = $input->fetch;
ok($rec, "fetch $mfn");
cmp_ok($rec->{'000'}->[0], '==', $mfn, 'has mfn');
cmp_ok($input->pos, '==', $mfn, "pos $mfn");
+
+ ok( my $txt = $rec->{'E'}, 'E' );
+ diag Dump( $txt ) if $debug;
+ ok( Encode::is_utf8( $txt, 1 ), 'utf8' );
diag "rec: ", dump($rec), "\n" if $debug;
}
FFSF,2221,50113,RARITETI,"Luna : Belletristisches Beiblatt der Agramer Zeitung",1333-5820,"Knj. 1838 - 1857"
,,50116,,"Godišnjak Ogranka Matice hrvatske Beli Manastir",1845-044X,
FFAN,,50304,,Scrutiny,,
+FFSF,387,50060,,"Lingvist : Časopis za strane jezike Saveza stručnih prevodilaca Jugoslavije",,"God.1(1963) - 2-3(1964-1965)"
+FFSF,97,50061,,"Naše řeč",0027-8203,"Roč.49(1966) ; 52(1969) ; 54(1971)-55(1972) ; 57(1974)-72-73(1989-90) ; 76(1993)/7972"
+FFSF,389,50065,,"Glossy : Poświęcone kulturze i piśmiennictwu",,"Rok 1(1939)-Zes.1-2,3"
+FFSF,220,50093,,"Libra : Zbornik SC Književnog kluba",0352-9126,Sv.4(1996)/8311