#
# 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);
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
sub NormalizeString{
my ($string,$nfd,$transform)=@_;
- utf8::decode($string) unless (utf8::is_utf8($string));
+ return $string unless defined($string); # force scalar context return.
+ $string = Encode::decode('UTF-8', $string) unless (Encode::is_utf8($string));
if ($nfd){
$string= NFD($string);
}
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;
# occurs, upgrade the string in place. Moral of the story seems to be
# that pack("U", ...) is better than chr(...) if you need to guarantee
# that the resulting string is UTF-8.
- utf8::upgrade($utf8sf);
+ $utf8sf = Encode::encode('UTF-8', $utf8sf);
}
push @converted_subfields, $subfield->[0], $utf8sf;
}