Changeset 24028


Ignore:
Timestamp:
05/18/11 20:42:54 (10 years ago)
Author:
ak19
Message:

Bugfix for PagedImagePlugin dealing incorrectly with accented characters when working with item files in XML.

File:
1 edited

Legend:

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

    r23561 r24028  
    134134package PagedImagePlugin;
    135135
     136use Encode;
    136137use ReadXMLFile;
    137138use ReadTextFile;
     
    485486    $self->{'current_section'} = $doc_obj->get_parent_section($self->{'current_section'});
    486487    } elsif ($element eq "Metadata") {
    487     my $meta_name = $self->{'metadata_name'};
     488   
     489    # text read in by XML::Parser is in Perl's binary byte value
     490    # form ... need to explicitly make it UTF-8     
     491    my $meta_name = decode("utf-8",$self->{'metadata_name'});
     492    my $metadata_value = decode("utf-8",$self->{'metadata_value'});
     493   
    488494    if ($meta_name =~ /\./) {
    489495        $meta_name = "ex.$meta_name";
    490496    }
    491     $doc_obj->add_utf8_metadata ($self->{'current_section'}, $meta_name, $self->{'metadata_value'});
     497   
     498    $doc_obj->add_utf8_metadata ($self->{'current_section'}, $meta_name, $metadata_value);
    492499    $self->{'metadata_name'} = "";
    493500    $self->{'metadata_value'} = "";
     
    627634    my $num = 0;
    628635    while (defined ($line = <ITEMFILE>)) {
     636   
     637    # text read in by XML::Parser is in Perl's binary byte value
     638    # form ... need to explicitly make it UTF-8
     639    $line = decode("utf-8",$line);
     640   
    629641    next unless $line =~ /\w/;
    630642    chomp $line;
     
    706718
    707719    my $text="";
    708     &ReadTextFile::read_file($self, $filename_full_path, $encoding, $language, \$text);
     720    &ReadTextFile::read_file($self, $filename_full_path, $encoding, $language, \$text); # already decoded as utf8
    709721    if (!length ($text)) {
    710722    # It's a bit unusual but not out of the question to have no text, so just give a warning
Note: See TracChangeset for help on using the changeset viewer.