Hi,

I'm trying to create MARCXML records with data extracted from MySQL, in
which some of the records are in Arabic. I'm using MARC::Record (2.0.3),
MARC::File::XML (0.93) and DBD::mysql (4.012).

The output into ISO2709 shows the Arabic utf8 strings correctly with
following code snippet:

$dbh = DBI->connect ($dsn, $user, $pass, { RaiseError => 1, *
mysql_enable_utf8* => 1 });
...
open (ISO, ">$file");
my $record = MARC::Record->new();
...
print ISO $record->as_usmarc;

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'
);
=> $xml = MARC::File::XML->out( $file, 'utf8' );
=> $xml->write( $record, 'utf8' );
=> $record->encoding( 'UTF-8' );
...

Since the ISO2709 output is coming correctly, I can use tools like MARCEdit
to convert it into MARCXML. But I have to give this script to a colleague
and really want to avoid the extra step. Any hint on what's going wrong?

Regards,
Saiful Amin
+91-9343826438

Reply via email to