[Melbourne-pm] Decoding =?ISO-8859-1...

Stephen Edmonds melbourne-pm at popcorn.cx
Sat Jul 19 17:40:37 PDT 2008


Nate,

ISO-8859-1 is not the encoding of the subject, it is an indication of 
the encoding of the original string before it was put into MIME 
encoded-word. [1]

You need to use Encode::MIME::Header, but that is simply part of Encode 
so you need to do is:

   $text = decode('MIME-Header', $subj)

This gives a text string of the original subject.  If you are going to 
transmit it as UTF8 that is when you use decode() to give you a binary 
string from the text string.

Thanks,

Stephen

[1] http://en.wikipedia.org/wiki/MIME#Encoded-Word

Nathan Bailey wrote:
> I know this should be trivial, but for some reason, I can't change:
> =?ISO-8859-1?B?U2Nhbm5lZCBmcm9tIE1GUC0w?=  
> =?ISO-8859-1?B?MEY1NzYzMSAwNy8xNi8yMDA4?= =?ISO-8859-1?B?IDE1OjMz?=
> into "Scanned from MFP-00F57631 07/16/2008 15:33"
> 
> I've tried just decoding ISO-8859-1, I've tried decoding and re-encoding 
> as utf8, and I've even tried Unicode::String, but I still seem to end up 
> with the same input as output.
> 
> Help? :-)
> 
> code examples:
> 
> use Encode;
> $subj = encode("utf8", decode('ISO-8859-1', $subj));
> 
> use Unicode::String;
> Unicode::String->stringify_as( 'utf8' );
> my $string_utf8 = Unicode::String::latin1( $subj );
> 
> ta,
> N
> _______________________________________________
> Melbourne-pm mailing list
> Melbourne-pm at pm.org
> http://mail.pm.org/mailman/listinfo/melbourne-pm

-- 
                                  _     _   _
Stephen Edmonds                _/ \_  / \_/ \
Melbourne, Australia          <_ " _>   / \
                                / O \   / " \
stephen at popcorn.cx            / ___ \  | O |
http://popcorn.cx/            \_____/  \___/


More information about the Melbourne-pm mailing list