From 4ce57a102b1c0404bc4ae67032bcb1cbbc769fc7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Demians?= Date: Sat, 27 Aug 2011 13:32:08 +0200 Subject: [PATCH] Bug 6799 rebuild_zebra.pl -x produces invalid XML records This patch allow to handle properly items containing extended characters and send valid XML records to zebraidx Signed-off-by: Julian Maurice Signed-off-by: Paul Poulain --- misc/migration_tools/rebuild_zebra.pl | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl index 6fa6501e42..fa87f22a91 100755 --- a/misc/migration_tools/rebuild_zebra.pl +++ b/misc/migration_tools/rebuild_zebra.pl @@ -323,19 +323,17 @@ sub export_marc_records_from_sth { my @items = GetItemsInfo($record_number); if (@items){ my $record = MARC::Record->new; + $record->encoding('UTF-8'); my @itemsrecord; foreach my $item (@items){ my $record = Item2Marc($item, $record_number); push @itemsrecord, $record->field($itemtag); } $record->insert_fields_ordered(@itemsrecord); - my $itemsxml=$record->as_xml_record(); - my $searchstring = '\n'; - my $index = index($itemsxml, '\n', 0); - $itemsxml = substr($itemsxml, $index + length($searchstring)); - $searchstring = ''; - $marcxml = substr($marcxml, 0, index($marcxml, $searchstring)); - $marcxml .= $itemsxml; + my $itemsxml = $record->as_xml_record(); + $marcxml = + substr($marcxml, 0, length($marcxml)-10) . + substr($itemsxml, index($itemsxml, "\n", 0) + 10); } } if ( $marcxml ) { -- 2.39.5