If MARC::File::XML->as_xml_record() receives a record with anything other
than 'a' in LDR/09 position, it will try to run a MARC8-to-UTF8 conversion
on the record - even though the source file itself was XML and clearly
couldn't have been MARC8.
This code corrects the leader on the fly so that MARC::File::XML won't
try to convert it and throw a "wide character" warning, but the fix
means that something was wrong with the leader to begin with, so we also
write a warning to the log about the situation.
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16925
dcc99617-32d9-48b4-a31d-
7c20da2025e4
$logger->info("processing record $count");
try {
+ # Avoid an over-eager MARC::File::XML that may try to convert
+ # our record from MARC8 to UTF8 and break because the record
+ # is obviously already UTF8
+ my $ldr = $r->leader();
+ if (($marctype eq 'XML') && (substr($ldr, 9, 1) ne 'a')) {
+ $logger->warn("MARCXML record LDR/09 was not 'a'; record leader may be corrupt");
+ substr($ldr,9,1,'a');
+ $r->leader($ldr);
+ }
(my $xml = $r->as_xml_record()) =~ s/\n//sog;
$xml =~ s/^<\?xml.+\?\s*>//go;
$xml =~ s/>\s+</></go;