Changeset 4791


Ignore:
Timestamp:
2003-06-25T09:44:33+12:00 (21 years ago)
Author:
davidb
Message:

Modified so -input_encoding flag used.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/MARCPlug.pm

    r4785 r4791  
    159159
    160160
     161# The bulk of this function is based on read_line in multiread.pm
     162# Unable to use read_line original because it expects to get its input
     163# from a file.  Here the line to be converted is passed in as a string
     164
     165sub to_utf8
     166{
     167    my $self = shift (@_);
     168    my ($encoding, $line) = @_;
     169
     170    if ($encoding eq "iso_8859_1") {
     171    # we'll use ascii2utf8() for this as it's faster than going
     172    # through convert2unicode()
     173    return &unicode::ascii2utf8 (\$line);
     174    }
     175
     176    # everything else uses unicode::convert2unicode
     177    return &unicode::unicode2utf8 (&unicode::convert2unicode ($encoding, \$line));
     178}
     179
     180
    161181sub read_file {
    162182    my $self = shift (@_);
    163183    my ($filename, $encoding, $language, $textref) = @_;
     184
     185    $self->{'readfile_encoding'} = $encoding;
    164186
    165187    @marc_entries = ();
     
    214236    $$textref =~ s/>/>/g;
    215237
     238    my $encoding = $self->{'readfile_encoding'};
     239    $$textref = $self->to_utf8($encoding,$$textref);
     240
    216241    print $outhandle "  Adding Marc Record:\n",substr($$textref,0,40), " ...\n"
    217242    if $self->{'verbosity'} > 2;
     
    231256    my ($marc, $metadata, $doc_obj, $section) = @_;
    232257    my $outhandle = $self->{'outhandle'};
     258
     259    my $encoding = $self->{'readfile_encoding'};
    233260
    234261    my $metadata_mapping = $self->{'metadata_mapping'};
     
    245272        foreach $metavalue ( @metavalues )
    246273        {
    247         $doc_obj->add_utf8_metadata ($thissection, $metaname, $metavalue->as_string());
     274        $metavalue_str = $self->to_utf8($encoding,$metavalue->as_string());
     275        $doc_obj->add_utf8_metadata ($thissection, $metaname, $metavalue_str);
    248276        }
    249277    }
Note: See TracChangeset for help on using the changeset viewer.