# 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 Modern::Perl;
-use MARC::Charset qw/marc8_to_utf8/;
+use MARC::Charset;
use Text::Iconv;
-use C4::Debug;
-use Unicode::Normalize;
-use Encode qw( decode encode is_utf8 );
+use Unicode::Normalize qw( NFC NFD );
+use Encode;
-use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+use Koha::Logger;
+our (@ISA, @EXPORT_OK);
BEGIN {
- # set the version for version checking
- $VERSION = 3.07.00.049;
require Exporter;
@ISA = qw(Exporter);
- @EXPORT = qw(
+ @EXPORT_OK = qw(
NormalizeString
IsStringUTF8ish
MarcToUTF8Record
# If we do not know the source encoding, try some guesses
# as follows:
# 1. Record is UTF-8 already.
- # 2. If MARC flavor is MARC21 or NORMARC, then
+ # 2. If MARC flavor is MARC21, then
# a. record is MARC-8
# b. record is ISO-8859-1
# 3. If MARC flavor is UNIMARC, then
if (not defined $source_encoding) {
if ($marc_blob_is_utf8) {
- # note that for MARC21/NORMARC we are not bothering to check
+ # note that for MARC21 we are not bothering to check
# if the Leader/09 is set to 'a' or not -- because
# of problems with various ILSs (including Koha in the
# past, alas), this just is not trustworthy.
SetMarcUnicodeFlag($marc_record, $marc_flavour);
return $marc_record, 'UTF-8', [];
} else {
- if ($marc_flavour eq 'MARC21' || $marc_flavour eq 'NORMARC') {
+ if ($marc_flavour eq 'MARC21') {
return _default_marc21_charconv_to_utf8($marc_record, $marc_flavour);
} elsif ($marc_flavour =~/UNIMARC/) {
return _default_unimarc_charconv_to_utf8($marc_record, $marc_flavour);
my $marc_flavour = shift; # || C4::Context->preference("marcflavour");
$marc_record->encoding('UTF-8');
- if ($marc_flavour eq 'MARC21' || $marc_flavour eq 'NORMARC') {
+ if ($marc_flavour eq 'MARC21') {
my $leader = $marc_record->leader();
substr($leader, 9, 1) = 'a';
$marc_record->leader($leader);
$marc_record->insert_grouped_field(
MARC::Field->new( 100, '', '', "a" => $string ) );
}
- $debug && warn "encodage: ", substr( $marc_record->subfield(100, 'a'), $encodingposition, 3 );
+ Koha::Logger->get->debug("encodage: ", substr( $marc_record->subfield(100, 'a'), $encodingposition, 3 ));
} else {
warn "Unrecognized marcflavour: $marc_flavour";
}
my $record_modified = 0;
my $frameworkcode = C4::Biblio::GetFrameworkCode($biblionumber);
my ( $url_field, $url_subfield ) =
- C4::Biblio::GetMarcFromKohaField( 'biblioitems.url', $frameworkcode );
+ C4::Biblio::GetMarcFromKohaField( 'biblioitems.url' );
foreach my $field ( $record->fields() ) {
if ( $field->is_control_field() ) {
my $value = $field->data();
replacement character. This is meant as a last-ditch
method, and would be best used as part of a UI that
lets a cataloguer pick various character conversions
-until he or she finds the right one.
+until they find the right one.
=cut