Bug 14687: Patron's transaction history changes items' order after paying fines.
[koha-ffzg.git] / C4 / Charset.pm
index 6bfd935..667c2d2 100644 (file)
@@ -4,27 +4,27 @@ package C4::Charset;
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use strict;
 use warnings;
 
 use MARC::Charset qw/marc8_to_utf8/;
 use Text::Iconv;
-use C4::Context;
 use C4::Debug;
 use Unicode::Normalize;
+use Encode qw( decode encode is_utf8 );
 
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
@@ -111,8 +111,8 @@ will assume that this situation occur does not very often.
 sub IsStringUTF8ish {
     my $str = shift;
 
-    return 1 if utf8::is_utf8($str);
-    return utf8::decode($str);
+    return 1 if Encode::is_utf8($str);
+    return utf8::decode( $str );
 }
 
 =head2 SetUTF8Flag
@@ -180,7 +180,7 @@ Sample code :
 sub NormalizeString{
        my ($string,$nfd,$transform)=@_;
     return $string unless defined($string); # force scalar context return.
-       utf8::decode($string) unless (utf8::is_utf8($string));
+    $string = Encode::decode('UTF-8', $string) unless (Encode::is_utf8($string));
        if ($nfd){
                $string= NFD($string);
        }
@@ -332,6 +332,7 @@ sub SetMarcUnicodeFlag {
         substr($leader, 9, 1) = 'a';
         $marc_record->leader($leader); 
     } elsif ($marc_flavour =~/UNIMARC/) {
+        require C4::Context;
        my $defaultlanguage = C4::Context->preference("UNIMARCField100Language");
         $defaultlanguage = "fre" if (!$defaultlanguage || length($defaultlanguage) != 3);
         my $string;