Changeset 536

Show
Ignore:
Timestamp:
04/04/06 19:02:11
Author:
miyagawa
Message:

falls back to detection mode if encoding is not valid

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Util.pm

    r518 r536  
    6262    $charset ||= 'utf-8'; 
    6363 
    64     return Encode::decode($charset, $content); 
     64    my $content = eval { Encode::decode($charset, $content) }; 
     65 
     66    if ($@ && $@ =~ /Unknown encoding/) { 
     67        Plagger->context->log(warn => $@); 
     68        $charset = $Detector->($content) || 'utf-8'; 
     69        $content = Encode::decode($charset, $content); 
     70    } 
     71 
     72    $content; 
    6573} 
    6674