Re: MARC::File::XML utf8 output problem

[email protected] (Frédéric DEMIANS) Tue, 08 Mar 2011 12:00:30 +0100
Newsgroups perl.perl4lib
Message-ID <[email protected]>
 > However, when I try to generate MARCXML output with following code the
 > Arabic characters gets corrupted:

 > $xml = MARC::File::XML->out( $file );
 > my $record = MARC::Record->new();
 > ...
 > $xml->write( $record );
 > ...
 > $xml->close();

 > I've tried setting the encoding in various ways without success, e.g.:
 > => use MARC::File::XML ( BinaryEncoding => 'utf8', RecordFormat =>
 > 'USMARC'

What is the value of you records leader position 9? If you have anything
else than 'a', MARC::File::XML->write method will transcode your biblio
records from marc8 to utf8 encoding. That's bad if your records are
already UTF-8 encoded.

You can try forcing your records 9 position before writing them:

   my $leader = $record->leader;
   substr($leader, 9, 1, 'a');
   $record->leader( $leader );

-- 
Frédéric DEMIANS
http://www.tamil.fr/u/fdemians.html