line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MARC::File::Encode; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
MARC::File::Encode - Encode wrapper for MARC::Record |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Encode.pm exports encode() by default, and MARC::File::USMARC |
10
|
|
|
|
|
|
|
already has a function encode() so we need this wrapper to |
11
|
|
|
|
|
|
|
keep things the way they are. I was half tempted to change |
12
|
|
|
|
|
|
|
MARC::File::USMARC::encode() to something else but there could |
13
|
|
|
|
|
|
|
very well be code in the wild that uses it directly and I don't |
14
|
|
|
|
|
|
|
want to break backwards compat. This probably comes with a performance |
15
|
|
|
|
|
|
|
hit of some kind. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
28
|
|
|
28
|
|
309
|
use strict; |
|
28
|
|
|
|
|
51
|
|
|
28
|
|
|
|
|
924
|
|
20
|
28
|
|
|
28
|
|
149
|
use warnings; |
|
28
|
|
|
|
|
55
|
|
|
28
|
|
|
|
|
842
|
|
21
|
28
|
|
|
28
|
|
157
|
use base qw( Exporter ); |
|
28
|
|
|
|
|
56
|
|
|
28
|
|
|
|
|
2974
|
|
22
|
28
|
|
|
28
|
|
38996
|
use Encode; |
|
28
|
|
|
|
|
437210
|
|
|
28
|
|
|
|
|
5515
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our @EXPORT_OK = qw( marc_to_utf8 ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 marc_to_utf8() |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Simple wrapper around Encode::decode(). |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub marc_to_utf8 { |
33
|
|
|
|
|
|
|
# if there is invalid utf8 date then this will through an exception |
34
|
|
|
|
|
|
|
# let's just hope it's valid :-) |
35
|
1
|
|
|
1
|
1
|
6
|
return decode( 'UTF-8', $_[0], 1 ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |