| 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 | 29 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | 29 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | 29 | ▶ | use base qw( Exporter ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 22 | 29 | ▶ | use Encode; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | |||
| 24 | 29 | 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 | 1 | ▶ | sub marc_to_utf8 { |
|
Subroutine
marc_to_utf8: called CC=1 SCAR=0.0
Pod
documented
| |||
| 33 | # if there is invalid utf8 date then this will through an exception | ||
| 34 | # let's just hope it's valid :-) | ||
| 35 | 1 | return decode( 'UTF-8', $_[0], 1 ); | |
| 36 | } | ||
| 37 | |||
| 38 | 29 | 1; | |