Lines 18-23
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 10; |
20 |
use Test::More tests => 10; |
|
|
21 |
use Encode qw( is_utf8 ); |
21 |
use MARC::Record; |
22 |
use MARC::Record; |
22 |
|
23 |
|
23 |
BEGIN { |
24 |
BEGIN { |
Lines 28-36
my $octets = "abc";
Link Here
|
28 |
ok(IsStringUTF8ish($octets), "verify octets are valid UTF-8 (ASCII)"); |
29 |
ok(IsStringUTF8ish($octets), "verify octets are valid UTF-8 (ASCII)"); |
29 |
|
30 |
|
30 |
$octets = "flamb\c3\a9"; |
31 |
$octets = "flamb\c3\a9"; |
31 |
ok(!utf8::is_utf8($octets), "verify that string does not have Perl UTF-8 flag on"); |
32 |
ok(!Encode::is_utf8($octets), "verify that string does not have Perl UTF-8 flag on"); |
32 |
ok(IsStringUTF8ish($octets), "verify octets are valid UTF-8 (LATIN SMALL LETTER E WITH ACUTE)"); |
33 |
ok(IsStringUTF8ish($octets), "verify octets are valid UTF-8 (LATIN SMALL LETTER E WITH ACUTE)"); |
33 |
ok(!utf8::is_utf8($octets), "verify that IsStringUTF8ish does not magically turn Perl UTF-8 flag on"); |
34 |
ok(!Encode::is_utf8($octets), "verify that IsStringUTF8ish does not magically turn Perl UTF-8 flag on"); |
34 |
|
35 |
|
35 |
$octets = "a\xc2" . "c"; |
36 |
$octets = "a\xc2" . "c"; |
36 |
ok(!IsStringUTF8ish($octets), "verify octets are not valid UTF-8"); |
37 |
ok(!IsStringUTF8ish($octets), "verify octets are not valid UTF-8"); |
Lines 45-58
$record->append_fields(
Link Here
|
45 |
MARC::Field->new('245', ' ', ' ', a => 'Rayuela'), |
46 |
MARC::Field->new('245', ' ', ' ', a => 'Rayuela'), |
46 |
); |
47 |
); |
47 |
# Verify our data serves its purpose |
48 |
# Verify our data serves its purpose |
48 |
ok( !utf8::is_utf8($record->subfield('100','a')) && |
49 |
ok( !Encode::is_utf8($record->subfield('100','a')) && |
49 |
!utf8::is_utf8($record->subfield('245','a')), |
50 |
!Encode::is_utf8($record->subfield('245','a')), |
50 |
'Verify that the subfields are NOT set the UTF-8 flag yet' ); |
51 |
'Verify that the subfields are NOT set the UTF-8 flag yet' ); |
51 |
|
52 |
|
52 |
SetUTF8Flag($record); |
53 |
SetUTF8Flag($record); |
53 |
|
54 |
|
54 |
ok( utf8::is_utf8($record->subfield('100','a')) && |
55 |
ok( Encode::is_utf8($record->subfield('100','a')) && |
55 |
utf8::is_utf8($record->subfield('245','a')), |
56 |
Encode::is_utf8($record->subfield('245','a')), |
56 |
'SetUTF8Flag sets the UTF-8 flag to all subfields' ); |
57 |
'SetUTF8Flag sets the UTF-8 flag to all subfields' ); |
57 |
|
58 |
|
58 |
1; |
59 |
1; |
59 |
- |
|
|