Changeset 27283 for main/trunk


Ignore:
Timestamp:
2013-05-01T18:03:33+12:00 (11 years ago)
Author:
ak19
Message:
  1. Fixed an encoding bug that Diego helpfully discovered. Metadata extracted from downloaded .oai files were double encoded. This was because we forgot to add a call to decode() after reading in the contents of the oai file, something we had remembered to do in many other plugins. 2. John Thompson recommended the very helpful Dump(dollar-var) function of Devel::Peek which dumps information about any var to stderr, including encoding information. For strings marked utf8 it also prints out hex and octal values for chars outside of Basic Latin.
File:
1 edited

Legend:

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

    r25333 r27283  
    2727package OAIPlugin;
    2828
     29# Devel::Peek's Dump($var) function is useful for debugging encoding issues.
     30#use Devel::Peek;
     31use Encode;
    2932use extrametautil;
    3033use unicode;
     
    500503    $self->open_prettyprint_metadata_table();
    501504
     505    # need to decode the string, else it will be double-encoded at this point
     506    $$textref = decode("utf-8",$$textref);
     507
     508# Debugging encoding issues with Devel::Peek's Dump() which prints octal and hexcode
     509#    print STDERR "#### text ref: $$textref\n";
     510#    print STDERR "\n@@@\n";
     511#    Dump($$textref);
     512#    print STDERR "\n";
     513
    502514    if ($$textref =~ m/<metadata\s*>(.*?)<\/metadata\s*>/s)
    503515    {
Note: See TracChangeset for help on using the changeset viewer.