in reply to Re: decoding a UTF-16B string found in an email subject
in thread decoding a UTF-16B string found in an email subject

thanks the doc for Encode::Mime::Header explained what i was doing wrong

#my $string = "=?UTF-16?B?dwAgAEMAcgBlAGQAaQB0ACAAQwBhAHIAZAAgAEMAbwB1 +AGwAZAAgAEIAZQAgAEgAZQBhAGQAZQBkACAAWQBvAHUAcgAgAFcAYQB5AA==?="; my $string = "dwAgAEMAcgBlAGQAaQB0ACAAQwBhAHIAZAAgAEMAbwB1AGwAZAAgAEIA +ZQAgAEgAZQBhAGQAZQBkACAAWQBvAHUAcgAgAFcAYQB5AA=="; print MIME::Base64::decode( $string ), "\n"; w Credit Card Could Be Headed Your Way

i had to use base64 decoding on the encoded word, and not the whole string

=?encoding?X?ENCODED WORD?=

Replies are listed 'Best First'.
Re^3: decoding a UTF-16B string found in an email subject
by runrig (Abbot) on Oct 30, 2013 at 20:32 UTC
    If you just subsitute 'UTF-16' with 'UTF-8', then the entire line is correctly decoded with decode('MIME-Header', $str). The encoded part appears to be incorrectly encoded. Probably typical of spammers...