From 7945aa8bbea4d08eb9865ee0e02767fe0ac8c581 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@biblibre.com>
Date: Fri, 30 Jan 2015 16:24:49 +0100
Subject: [PATCH] [SIGNED OFF] Bug 13646: Fix facets encoding problem for GSR1

Since bug 11944, the facets are not correctly encoded if the indexing
mode is GRS1.

In MARC::File::USMARC
  # if utf8 the we encode the string as utf8
  if ( $marc->encoding() eq 'UTF-8' ) {
      $tagdata = marc_to_utf8( $tagdata );
  }
$marc->encoding return 'MARC8' because the utf8 flag is not set on the marc record.

Test plan:
On an installation set with GRS1, launch a search and verify you have
facets correctly encoded.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
---
 C4/Search.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/C4/Search.pm b/C4/Search.pm
index 5216a12..4998c11 100644
--- a/C4/Search.pm
+++ b/C4/Search.pm
@@ -2594,7 +2594,9 @@ sub new_record_from_zebra {
         if ( $index_mode eq 'dom' ) {
             MARC::Record->new_from_xml( $raw_data, 'UTF-8' );
         } else {
-            MARC::Record->new_from_usmarc( $raw_data );
+            my $mr = MARC::Record->new_from_usmarc( $raw_data );
+            SetUTF8Flag($mr);
+            $mr;
         }
     };
 
-- 
2.3.0