From e2787e32d05ff89d4385e14671fcae33e75e7959 Mon Sep 17 00:00:00 2001 From: kados Date: Sat, 4 Mar 2006 17:10:48 +0000 Subject: [PATCH] VERY IMPORTANT NOTES!!! READ OR YOU MAY RUIN YOUR ENCODING Previous commits replaced the use of the MARChtml2marc routine with a MARChtml2xml that reads in the form data and converts it to a MARC::File::XML object. It then passes that to MARC::Record via the new_from_xml() method. This works perfectly and fixes all of the bugs with the old MARChtml2marc routine (see mail to koha-devel). However, there is one gotcha. The MARC::File::XML new_from_xml() method converts UTF-8 data into MARC-8 by default for historical reasons. This means that entry of characters outside the normal ascii range in UTF-8 will come out as gibberish in MARC-8. Never fear, there is a solution. This commit uses code written for MARC::File::XML version 0.82 to add the ability to specify the encoding desired (I chose UTF-8 because I can't think of a reason to ever need MARC-8) The bottom line is that to properly encode records YOU WILL HAVE TO UPDATE MARC::File::XML to at least CPAN verion 0.82 !!!!! --- acqui.simple/addbiblio.pl | 4 ++-- acqui.simple/additem.pl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/acqui.simple/addbiblio.pl b/acqui.simple/addbiblio.pl index 243f565e1a..e07b8696f5 100755 --- a/acqui.simple/addbiblio.pl +++ b/acqui.simple/addbiblio.pl @@ -430,7 +430,7 @@ if ($op eq "addbiblio") { my @ind_tag = $input->param('ind_tag'); my @indicator = $input->param('indicator'); my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag); - my $record=MARC::Record::new_from_xml($xml); + my $record=MARC::Record::new_from_xml($xml, 'UTF-8'); # check for a duplicate my ($duplicatebiblionumber,$duplicatebibid,$duplicatetitle) = FindDuplicate($record) if ($op eq "addbiblio") && (!$is_a_modif); my $confirm_not_duplicate = $input->param('confirm_not_duplicate'); @@ -481,7 +481,7 @@ if ($op eq "addbiblio") { $indicators{$ind_tag[$i]} = $indicator[$i]; } my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag); - my $record=MARC::Record::new_from_xml($xml); + my $record=MARC::Record::new_from_xml($xml, 'UTF-8'); #my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators); # adding an empty field my $field = MARC::Field->new("$addedfield",'','','$tagaddfield_subfield' => ""); diff --git a/acqui.simple/additem.pl b/acqui.simple/additem.pl index 0a5adb6056..a4de84e04c 100755 --- a/acqui.simple/additem.pl +++ b/acqui.simple/additem.pl @@ -80,7 +80,7 @@ if ($op eq "additem") { # $indicators{$ind_tag[$i]} = $indicator[$i]; #} my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag); - my $record=MARC::Record::new_from_xml($xml); + my $record=MARC::Record::new_from_xml($xml, UTF-8); #my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators); # if autoBarcode is ON, calculate barcode... if (C4::Context->preference('autoBarcode')) { @@ -138,7 +138,7 @@ if ($op eq "additem") { # $indicators{$ind_tag[$i]} = $indicator[$i]; #} my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag); - my $record=MARC::Record::new_from_xml($xml); + my $record=MARC::Record::new_from_xml($xml, UTF-8); #my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators); # MARC::Record builded => now, record in DB # warn "R: ".$record->as_formatted;