3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Test
::More tests
=> 11;
24 use open ':std', ':encoding(utf8)';
27 use_ok
('C4::Charset');
31 ok
(IsStringUTF8ish
($octets), "verify octets are valid UTF-8 (ASCII)");
33 $octets = "flamb\c3\a9";
34 ok
(!utf8
::is_utf8
($octets), "verify that string does not have Perl UTF-8 flag on");
35 ok
(IsStringUTF8ish
($octets), "verify octets are valid UTF-8 (LATIN SMALL LETTER E WITH ACUTE)");
36 ok
(!utf8
::is_utf8
($octets), "verify that IsStringUTF8ish does not magically turn Perl UTF-8 flag on");
38 $octets = "a\xc2" . "c";
39 ok
(!IsStringUTF8ish
($octets), "verify octets are not valid UTF-8");
41 ok
( !SetUTF8Flag
(), 'SetUTF8Flag returns undef if no record passed' );
43 my $record = MARC
::Record
->new();
44 ok
( !SetUTF8Flag
($record), 'SetUTF8Flag returns undef if the record has no subfields' );
45 # Add some fields/subfields
46 $record->append_fields(
47 MARC
::Field
->new('100', ' ', ' ', a
=> 'Julio Cortazar'),
48 MARC
::Field
->new('245', ' ', ' ', a
=> 'Rayuela'),
50 # Verify our data serves its purpose
51 ok
( !utf8
::is_utf8
($record->subfield('100','a')) &&
52 !utf8
::is_utf8
($record->subfield('245','a')),
53 'Verify that the subfields are NOT set the UTF-8 flag yet' );
57 ok
( utf8
::is_utf8
($record->subfield('100','a')) &&
58 utf8
::is_utf8
($record->subfield('245','a')),
59 'SetUTF8Flag sets the UTF-8 flag to all subfields' );
61 is
( nsb_clean
("Le Moyen Âge"), "Le Moyen Âge", "nsb_clean removes and " );