|
Lines 18-23
Link Here
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 16; |
20 |
use Test::More tests => 16; |
|
|
21 |
use Encode qw( is_utf8 ); |
| 22 |
|
| 21 |
use MARC::Record; |
23 |
use MARC::Record; |
| 22 |
|
24 |
|
| 23 |
use utf8; |
25 |
use utf8; |
|
Lines 40-48
my $octets = "abc";
Link Here
|
| 40 |
ok(IsStringUTF8ish($octets), "verify octets are valid UTF-8 (ASCII)"); |
42 |
ok(IsStringUTF8ish($octets), "verify octets are valid UTF-8 (ASCII)"); |
| 41 |
|
43 |
|
| 42 |
$octets = "flamb\c3\a9"; |
44 |
$octets = "flamb\c3\a9"; |
| 43 |
ok(!utf8::is_utf8($octets), "verify that string does not have Perl UTF-8 flag on"); |
45 |
ok(!Encode::is_utf8($octets), "verify that string does not have Perl UTF-8 flag on"); |
| 44 |
ok(IsStringUTF8ish($octets), "verify octets are valid UTF-8 (LATIN SMALL LETTER E WITH ACUTE)"); |
46 |
ok(IsStringUTF8ish($octets), "verify octets are valid UTF-8 (LATIN SMALL LETTER E WITH ACUTE)"); |
| 45 |
ok(!utf8::is_utf8($octets), "verify that IsStringUTF8ish does not magically turn Perl UTF-8 flag on"); |
47 |
ok(!Encode::is_utf8($octets), "verify that IsStringUTF8ish does not magically turn Perl UTF-8 flag on"); |
| 46 |
|
48 |
|
| 47 |
$octets = "a\xc2" . "c"; |
49 |
$octets = "a\xc2" . "c"; |
| 48 |
ok(!IsStringUTF8ish($octets), "verify octets are not valid UTF-8"); |
50 |
ok(!IsStringUTF8ish($octets), "verify octets are not valid UTF-8"); |
|
Lines 57-70
$record->append_fields(
Link Here
|
| 57 |
MARC::Field->new('245', ' ', ' ', a => 'Rayuela'), |
59 |
MARC::Field->new('245', ' ', ' ', a => 'Rayuela'), |
| 58 |
); |
60 |
); |
| 59 |
# Verify our data serves its purpose |
61 |
# Verify our data serves its purpose |
| 60 |
ok( !utf8::is_utf8($record->subfield('100','a')) && |
62 |
ok( !Encode::is_utf8($record->subfield('100','a')) && |
| 61 |
!utf8::is_utf8($record->subfield('245','a')), |
63 |
!Encode::is_utf8($record->subfield('245','a')), |
| 62 |
'Verify that the subfields are NOT set the UTF-8 flag yet' ); |
64 |
'Verify that the subfields are NOT set the UTF-8 flag yet' ); |
| 63 |
|
65 |
|
| 64 |
SetUTF8Flag($record); |
66 |
SetUTF8Flag($record); |
| 65 |
|
67 |
|
| 66 |
ok( utf8::is_utf8($record->subfield('100','a')) && |
68 |
ok( Encode::is_utf8($record->subfield('100','a')) && |
| 67 |
utf8::is_utf8($record->subfield('245','a')), |
69 |
Encode::is_utf8($record->subfield('245','a')), |
| 68 |
'SetUTF8Flag sets the UTF-8 flag to all subfields' ); |
70 |
'SetUTF8Flag sets the UTF-8 flag to all subfields' ); |
| 69 |
|
71 |
|
| 70 |
is( nsb_clean("Le Moyen Âge"), "Le Moyen Âge", "nsb_clean removes and " ); |
72 |
is( nsb_clean("Le Moyen Âge"), "Le Moyen Âge", "nsb_clean removes and " ); |
| 71 |
- |
|
|