On Tue, Mar 15, 2016 at 01:23:37PM +0100, Gabriel Philippe wrote:
> 
> Quite funny, I spent some time on it yesterday...
> 
> This is rfc2047 encoding [1]. It can probably use other charsets (not
> only UTF-8).
> 
> The best way I found is to pipe it through perl -MEncode -ne 'print
> encode("UTF8",decode("MIME-Header",$_))'. But if Ionel's explanation
> is correct, a simple regexp and base64 -d would be quicker. Don't
> hesitate to give us feedback. :)

Well, while at it with the (in-)famous swiss-army chainsaw, I
came to fixing a few more things on the subject:

    $osubject = $subject;
    $subject = decode('MIME-Header', $subject);
    $subject =~ s/\[.*?\] +//g if @ARGV && $ARGV[0] eq '[]';
    $subject =~ s/((Re(\^[2-9]|\[[2-9]\])?|AW|WG|Antw(ort)?)\.?:\s*)+/Re: /ig;
    $subject = encode((($subject =~ /[\000-\037\200-\377]/)?'MIME-Q':'UTF8'), 
$subject);
    print "Subject: $subject\n";
    print "X-Original-Subject: $osubject\n" if $subject ne $osubject;

Bye,

Joerg

Attachment: signature.asc
Description: PGP signature

Reply via email to