It might just do what I need in Perl 6, but not in Perl 5.

I have experimented with MIME::WordDecoder. AFAICT in Perl 5 it only allows you to do a destructive mapping onto an 8 bit character set. It loses most of the information and leaves you no way to recreate the original data.

#!/usr/local/bin/perl5.8.5 use strict; use MIME::WordDecoder; my $field='From: =?koi8-r?B?7s/Xb2PUdSDT1NLBeG/Xwc7J0Q==?= <m2z19uyn1b +@rrpa.com>'; my $decoded = unmime( $field ); print $decoded
produces
./decode.pl ignoring text in character set `KOI8-R' at ./decode.pl line 7 From: 1 <m2z19uyn1b@rrpa.com>

Essentially it's just thrown away the KOI8-R characters because they don't map onto ISO-8859, or possibly because it just doesn't understand KOI8-R.

Of course if you can prove me wrong, I would be happy to be corrected. Maybe I just need to invoke it slightly differently?

I've been experimenting with Python 2.3 and it seems much more capable in this area, so I think I'll have to learn another scripting language :-(

$ python2.3 Python 2.3.4 (#1, Aug 3 2004, 16:01:36) [GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-110)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from email.Header import Header >>> from email.Header import decode_header >>> h='From: =?koi8-r?B?7s/Xb2PUdSDT1NLBeG/Xwc7J0Q==?= <m2z19uyn1b@rrp +a.com>' >>> decode_header( h ) [('From:', None), ('\xee\xcf\xd7oc\xd4u \xd3\xd4\xd2\xc1xo\xd7\xc1\xce +\xc9\xd1', 'koi8-r'), ('<m2z19uyn1b@rrpa.com>', None)] >>> h = Header('\xee\xcf\xd7oc\xd4u \xd3\xd4\xd2\xc1xo\xd7\xc1\xce\xc9 +\xd1', 'koi8-r') >>> print h =?koi8-r?b?7s/Xb2PUdSDT1NLBeG/Xwc7J0Q==?= >>>

In reply to Re^2: MIME nasties by tsr2
in thread MIME nasties by tsr2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.