sub _print_to_csv {
my ( $header, $results ) = @_;
- binmode STDOUT, ":encoding(UTF-8)";
+ binmode STDOUT, ':encoding(UTF-8)';
my $csv = Text::CSV_XS->new(
{ sep_char => $del,
use C4::Context;
use C4::AuthoritiesMarc;
use utf8;
-use open qw( :std :utf8 );
+use open qw[ :std :encoding(utf8) ];
my $dbh=C4::Context->dbh;
my $datatypes_query = $dbh->prepare(<<ENDSQL);
use MARC::File::XML;
use MARC::File::USMARC;
-use open OUT => ':utf8';
+use open OUT => ':encoding(UTF-8)';
use Getopt::Long qw(:config auto_help auto_version);
use Pod::Usage;
# these are the fields that will be substituted into <<item.content>>
my @item_content_fields = split( /,/, $itemscontent );
-binmode( STDOUT, ":utf8" );
+binmode STDOUT, ':encoding(UTF-8)';
our $csv; # the Text::CSV_XS object
#ATTENTION : Mettre la base en utf8 auparavant.
#BEWARE : Set database into utf8 before.
while (my ($authid)=$rq->fetchrow){
-open FILEOUTPUT,">:utf8", "./$filename/$authid.xml" or die "unable to open $filename";
+open my $fileoutput, '>:encoding(UTF-8)', "./$filename/$authid.xml" or die "unable to open $filename";
my $record=AUTHgetauthority($dbh,$authid);
if (! utf8::is_utf8($record)) {
utf8::decode($record);
# } else {
# $record->encoding( 'UTF-8' );
# }
- print FILEOUTPUT $record->as_xml();
-close FILEOUPUT;
+ print {$fileoutput} $record->as_xml();
+close $fileoutput;
}
use IO::File;
use Pod::Usage;
-binmode(STDOUT, ":utf8");
+binmode STDOUT, ':encoding(UTF-8)';
my ( $input_marc_file, $number, $offset) = ('',0,0);
my ($version, $delete, $test_parameter, $skip_marc8_conversion, $char_encoding, $verbose, $commit, $fk_off,$format,$biblios,$authorities,$keepids,$match, $isbn_check, $logfile);
my ($sourcetag,$sourcesubfield,$idmapfl);
my ($record_type, $sth, $directory, $as_xml, $noxml, $nosanitize) = @_;
my $num_exported = 0;
- open (OUT, ">:utf8 ", "$directory/exported_records") or die $!;
+ open my $fh, '>:encoding(UTF-8) ', "$directory/exported_records" or die $!;
my $i = 0;
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",'');
while (my ($record_number) = $sth->fetchrow_array) {
}
}
if ( $marcxml ) {
- print OUT $marcxml if $marcxml;
+ print {$fh} $marcxml if $marcxml;
$num_exported++;
}
next;
# to care, though, at least if you're using the GRS-1 filter. It does
# care if you're using the DOM filter, which requires valid XML file(s).
eval {
- print OUT ($as_xml) ? $marc->as_xml_record(C4::Context->preference('marcflavour')) : $marc->as_usmarc();
+ print {$fh} ($as_xml) ? $marc->as_xml_record(C4::Context->preference('marcflavour')) : $marc->as_usmarc();
$num_exported++;
};
if ($@) {
}
}
print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
- close OUT;
+ close $fh;
return $num_exported;
}
my ($record_type, $entries, $directory, $as_xml, $noxml, $records_deleted) = @_;
my $num_exported = 0;
- open (OUT, ">:utf8 ", "$directory/exported_records") or die $!;
+ open my $fh, '>:encoding(UTF-8)', "$directory/exported_records" or die $!;
my $i = 0;
# Skip any deleted records. We check for this anyway, but this reduces error spam
# strung together with no single root element. zebraidx doesn't seem
# to care, though, at least if you're using the GRS-1 filter. It does
# care if you're using the DOM filter, which requires valid XML file(s).
- print OUT ($as_xml) ? $marc->as_xml_record(C4::Context->preference('marcflavour')) : $marc->as_usmarc();
+ print {$fh} ($as_xml) ? $marc->as_xml_record(C4::Context->preference('marcflavour')) : $marc->as_usmarc();
$num_exported++;
}
}
print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
- close OUT;
+ close $fh;
return $num_exported;
}
my ($record_type, $entries, $directory, $as_xml) = @_;
my $records_deleted = {};
- open (OUT, ">:utf8 ", "$directory/exported_records") or die $!;
+ open my $fh, '>:encoding(UTF-8)', "$directory/exported_records" or die $!;
my $i = 0;
foreach my $record_number (map { $_->{biblio_auth_number} } @$entries ) {
print "\r$i" unless ($i++ %100 or !$verbose_logging);
fix_unimarc_100($marc);
}
- print OUT ($as_xml) ? $marc->as_xml_record(C4::Context->preference("marcflavour")) : $marc->as_usmarc();
+ print {$fh} ($as_xml) ? $marc->as_xml_record(C4::Context->preference("marcflavour")) : $marc->as_usmarc();
$records_deleted->{$record_number} = 1;
}
print "\nRecords exported: $i\n" if ( $verbose_logging );
- close OUT;
+ close $fh;
return $records_deleted;
# AUTHORITIES : copying mandatory files
#
unless (-f C4::Context->zebraconfig('authorityserver')->{config}) {
- open ZD,">:utf8 ",C4::Context->zebraconfig('authorityserver')->{config};
- print ZD "
+ open my $zd, '>:encoding(UTF-8)' ,C4::Context->zebraconfig('authorityserver')->{config};
+ print {$zd} "
# generated by KOHA/misc/migration_tools/rebuild_zebra.pl
profilePath:\${srcdir:-.}:$authorityserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/
# BIBLIOS : copying mandatory files
#
unless (-f C4::Context->zebraconfig('biblioserver')->{config}) {
- open ZD,">:utf8 ",C4::Context->zebraconfig('biblioserver')->{config};
- print ZD "
+ open my $zd, '>:encoding(UTF-8)', C4::Context->zebraconfig('biblioserver')->{config};
+ print {$zd} "
# generated by KOHA/misc/migrtion_tools/rebuild_zebra.pl
profilePath:\${srcdir:-.}:$biblioserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/
my $parser = XML::SAX::ParserFactory->parser(
Handler => MySAXHandler->new
);
-binmode STDOUT, ":utf8";
+binmode STDOUT, ':encoding(UTF-8)';
print "\x{65}\x{301}\n";
$parser->parse_string(encode_utf8("<xml>\x{65}\x{301}</xml>"));
$parser->parse_string("<xml>\xEF\xBB\xBF\x{65}\x{301}</xml>");
print STDERR "$0: Outputting to STDOUT...\n" if $verbose_p;
open(OUTPUT, ">&STDOUT");
}
-#binmode( OUTPUT, ":utf8" );
+binmode OUTPUT, ':encoding(UTF-8)';
if (defined $files_from) {
print STDERR "$0: Opening input file list \"$files_from\"\n" if $verbose_p;
}
# Output XML by passing the hashref to XMLOut
-binmode(STDOUT, ":utf8");
+binmode STDOUT, ':encoding(UTF-8)';
print CGI::header('-type'=>'text/xml', '-charset'=>'utf-8');
print XMLout(
$out,
);
}
-binmode( STDOUT, ":utf8" );
+binmode STDOUT, ':encoding(UTF-8)';
my $repository = C4::OAI::Repository->new();
# __END__ Main Prog
}
elsif ($phase eq 'Export'){
- binmode STDOUT, ':utf8';
+ binmode STDOUT, ':encoding(UTF-8)';
# export results to tab separated text or CSV
my $sql = $input->param('sql'); # FIXME: use sql from saved report ID#, not new user-supplied SQL!
$template->param(datas => \@datas,
do_it => 1);
}else{
- binmode STDOUT, ':utf8';
+ binmode STDOUT, ':encoding(UTF-8)';
print $input->header(-type => 'application/vnd.sun.xml.calc',
-encoding => 'utf-8',
-name => "$basename.csv",
use XML::Simple;
my $query = new CGI;
-binmode STDOUT, ":utf8";
+binmode STDOUT, ':encoding(UTF-8)';
my ($status, $cookie, $sessionID) = check_api_auth($query, { editcatalogue => 'edit_catalogue'} );
unless ($status eq "ok") {
use C4::Charset;
my $query = new CGI;
-binmode STDOUT, ":utf8";
+binmode STDOUT, ':encoding(UTF-8)';
my ($status, $cookie, $sessionID) = check_api_auth($query, { editcatalogue => 'edit_catalogue'} );
unless ($status eq "ok") {
mkdir "$directory/$record_type";
my $sth = $dbh->prepare($record_type eq "biblio" ? "SELECT marc FROM biblioitems" : "SELECT marc FROM auth_header");
$sth->execute();
- open OUT, ">:utf8", "$directory/$record_type/records";
+ open my $out, '>:encoding(UTF-8)', "$directory/$record_type/records";
while (my ($blob) = $sth->fetchrow_array) {
- print OUT $blob;
+ print {$out} $blob;
}
- close OUT;
+ close $out;
my $zebra_server = "${record_type}server";
my $zebra_config = C4::Context->zebraconfig($zebra_server)->{'config'};
my $zebra_db_dir = C4::Context->zebraconfig($zebra_server)->{'directory'};
}
if ($op eq "export") {
- binmode(STDOUT,":utf8");
+ binmode STDOUT, ':encoding(UTF-8)';
print $query->header( -type => 'application/octet-stream',
-charset => 'utf-8',
-attachment=>$filename);