From f8e83c35c7efff830036eab79a9d826cd4c4e79f Mon Sep 17 00:00:00 2001 From: kados Date: Fri, 10 Mar 2006 02:35:07 +0000 Subject: [PATCH] IMPORTANT: MARC::Record objects coming in from the reservoir are probably going to be encoded as MARC-8. This enures that they will be converted into UTF-8 before being displayed to the user (if they are in fact MARC-8). It's most easily done by turning the record into a MARC::File::XML object and then going back to MARC::Record -- easiest to do for me that is. Of course, a better solution is to create a routine that changes the encoding of a MARC::Record object (I was surprised to find such did not exist). I have tested this method for MARC21, but I'm not familiar with the issues with encoding in UNIMARC: are UNIMARC records ever encoded in charater sets other than MARC-8 and UTF-8? (if so, I will need to adjust this code). --- acqui.simple/addbiblio.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/acqui.simple/addbiblio.pl b/acqui.simple/addbiblio.pl index f484afc18d..6d5c4ed42d 100755 --- a/acqui.simple/addbiblio.pl +++ b/acqui.simple/addbiblio.pl @@ -164,6 +164,9 @@ sub build_authorized_values_list ($$$$$) { =cut sub create_input () { my ($tag,$subfield,$value,$i,$tabloop,$rec,$authorised_values_sth) = @_; + # must be encoded as utf-8 before it reaches the editor + use Encode; + $value = encode('utf-8', $value); $value =~ s/"/"/g; my $dbh = C4::Context->dbh; my %subfield_data; @@ -430,6 +433,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); + warn "XML HERE".$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); @@ -512,8 +516,10 @@ if ($op eq "addbiblio") { $bibid = ""; $oldbiblionumber= ""; } - - build_tabs ($template, $record, $dbh,$encoding); + #FIXME: it's kind of silly to go from MARC::Record to MARC::File::XML and then back again just to fix the encoding + my $uxml = $record->as_xml; + my $urecord = MARC::Record::new_from_xml($uxml, 'UTF-8'); + build_tabs ($template, $urecord, $dbh,$encoding); build_hidden_data; $template->param( oldbiblionumber => $oldbiblionumber, -- 2.39.5