[Koha-patches] [PATCH] [SIGNED-OFF] Bug 5883 : Prevent re-encoding the items if they are already in UTF-8 in ModBiblio.
Julian Maurice
julian.maurice at biblibre.com
Wed Mar 23 15:19:57 CET 2011
From: Frédérick Capovilla <frederick.capovilla at sys-tech.net>
Signed-off-by: Julian Maurice <julian.maurice at biblibre.com>
---
C4/Biblio.pm | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/C4/Biblio.pm b/C4/Biblio.pm
index 8143ee1..1b378df 100644
--- a/C4/Biblio.pm
+++ b/C4/Biblio.pm
@@ -320,10 +320,15 @@ sub ModBiblio {
foreach my $fielditem (@fields) {
my $field;
foreach ( $fielditem->subfields() ) {
+ # re-encode the subfield only if it isn't already in utf-8.
+ my ($tag, $value) = @$_;
+ $tag = Encode::encode('utf-8', $tag) unless utf8::is_utf8($tag);
+ $value = Encode::encode('utf-8', $value) unless utf8::is_utf8($value);
+
if ($field) {
- $field->add_subfields( Encode::encode( 'utf-8', $_->[0] ) => Encode::encode( 'utf-8', $_->[1] ) );
+ $field->add_subfields( $tag => $value );
} else {
- $field = MARC::Field->new( "$itemtag", '', '', Encode::encode( 'utf-8', $_->[0] ) => Encode::encode( 'utf-8', $_->[1] ) );
+ $field = MARC::Field->new( "$itemtag", '', '', $tag => $value );
}
}
$record->append_fields($field);
--
1.7.4.1
More information about the Koha-patches
mailing list