improved RSS for nntp.perl.org

TorgoX on 2003-06-16T09:53:47

Dear All,

In a fit of activity, I whipped up some code so that the RSS feeds at nntp.perl.org will do MIME-decoding, so that in the perl.copenhagen archives for example, you get "Næste møde" (Næste møde) instead of "=?iso-8859-1?Q?N=E6ste_m=F8de?=" in the XML. Me and Robert will get this working for the HTML views soon too.

For future reference, the magic I used was doing use Encode qw/decode/; use utf8; and then with a value in $_, ...

if( m/=?/ ) {
  s/\?unknown-8bit\?/?iso-8859-1?/gs; # our best bet
  eval { 
    # trap exceptions from unknown encodings
    my $x = decode( 'MIME-Header', $_);
    $_ = $x if utf8::valid($x);
  };
}


another solution...

sheriff_p on 2003-06-16T10:41:52

use MIME::WordDecoder; $subject = unmime($subject);

Typo

vsergu on 2003-06-16T15:02:47

m/=?/ should be m/=\?/, presumably. The first matches anything.

Re:Typo

TorgoX on 2003-06-17T16:08:22

Oops! You're right! I was so intent on whether I should add more context to the pattern, that I missed the fact I should escape the "?" ! Thanks for catching that!