Ignore:
Timestamp:
2011-05-19T17:51:07+12:00 (13 years ago)
Author:
ak19
Message:

Dr Bainbridge fixed the unicode issue that appeared after the 2.84 release, when the parser instantiation got changed (by removing its ProtocolEncoding argument, which used to set this encoding to Latin-1).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/MetadataXMLPlugin.pm

    r23895 r24060  
    147147
    148148    # create XML::Parser object for parsing metadata.xml files
    149     my $parser = new XML::Parser('Style' => 'Stream',
     149    my $parser = new XML::Parser('Style' => 'Stream',                             
     150                                  'Pkg' => 'MetadataXMLPlugin',
    150151                                  'PluginObj' => $self,
    151                                   'Pkg' => 'MetadataXMLPlugin',
    152                   'Handlers' => {'Char' => \&Char,
     152                    'Handlers' => {'Char' => \&Char,
    153153                         'Doctype' => \&Doctype
    154154                         });
     
    246246    my $filename = &util::filename_cat($base_dir, $file);
    247247    return undef unless $self->can_process_this_file($filename);   
    248 
     248   
    249249    $self->{'metadata-file'} = $file;
    250250    $self->{'metadata-filename'} = $filename;
     
    266266
    267267    if ($@) {
     268    print STDERR "**** Error is: $@\n";
    268269    my $plugin_name = ref ($self);
    269270    my $failhandle = $self->{'failhandle'};
     
    301302    my $self = shift(@_);
    302303    my ($expat, $element) = @_;
    303 
     304   
    304305    if ($element eq "FileSet") {
    305306    $self->{'saved_targets'} = [];
     
    356357    }
    357358    elsif ($element eq "Metadata") {
    358     my $metadata_name = decode("utf8",$self->{'metadata_name'});
    359     my $metadata_value = decode("utf8",$self->{'metadata_value'});
     359    # text read in by XML::Parser is in Perl's binary byte value
     360    # form ... need to explicitly make it UTF-8
     361   
     362    my $metadata_name = decode("utf-8",$self->{'metadata_name'});
     363    my $metadata_value = decode("utf-8",$self->{'metadata_value'});
    360364   
    361365    &metadatautil::store_saved_metadata($self,
     
    384388# things down significantly in some cases.
    385389sub Char {
    386     if ($]<5.008) {
    387     use bytes;  # Necessary to prevent encoding issues with XML::Parser 2.31+ and Perl 5.6
    388     }
     390    use bytes;  # Necessary to prevent encoding issues with XML::Parser 2.31+
     391
     392#    if ($]<5.008) {
     393#   use bytes;  # Necessary to prevent encoding issues with XML::Parser 2.31+ and Perl 5.6
     394#    }
    389395    $_[0]->{'Text'} .= $_[1];
    390396    return undef;
Note: See TracChangeset for help on using the changeset viewer.