Bug 6752: Be stricter with utf-8 encoding of output
[koha.git] / misc / migration_tools / 22_to_30 / export_Authorities_xml.pl
index 24dacad..42d2e5c 100755 (executable)
@@ -1,4 +1,12 @@
 #!/usr/bin/perl
+#use strict;
+#use warnings; FIXME - Bug 2505
+BEGIN {
+    # find Koha's Perl modules
+    # test carefully before changing this
+    use FindBin;
+    eval { require "$FindBin::Bin/../../kohalib.pl" };
+}
 use C4::Context;
 use MARC::File::XML(BinaryEncoding=>"utf8");
 use MARC::Record;
@@ -15,7 +23,7 @@ $rq->execute;
 #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);
@@ -36,7 +44,7 @@ open FILEOUTPUT,">:utf8", "./$filename/$authid.xml" or die "unable to open $file
      # } else {
 #    $record->encoding( 'UTF-8' );
 #  }
-  print FILEOUTPUT $record->as_xml();
-close FILEOUPUT;
+  print {$fileoutput}  $record->as_xml();
+close $fileoutput;
 
 }