in reply to Decoding an email body, into utf8

I think what you might be after is MIME::QuotedPrint. Here's your test re-written with that in mind:

#!/usr/bin/env perl use strict; use warnings; use MIME::QuotedPrint; my $message = q|testing a reply *Do it as *html=C2= =A0I guess Andy Newby=C2=A0 *Email:*=C2=A0 =C2=A0=C2=A0 andy@xx.co.u +k =C2=A0 * WWW: =C2=A0 =C2=A0=C2=A0 * http://www.xx.co.= uk =C2=A0 Mobile:=C2=A0* = =C2=A002269 201 576 =C2=A0=C2=A0 |; my $test = decode_qp($message); print "FOO: $test \n";

Does this give the output you were after?

Replies are listed 'Best First'.
Re^2: Decoding an email body, into utf8
by ultranerds (Hermit) on Jul 22, 2016 at 13:35 UTC
    Hi,

    Thanks - that kinda works :)

    The output I'm getting now in SSH, is:

    FOO: testing a reply *Do it as *html     I guess Andy Newby  *Email:*     andy@xx.co.uk   * WWW:      * http://www.xx.co.    uk   Mobile: *      07769 201 576    Thanks

    Andy

      And what output do you expect? It would help to see this in the form of a test eg. How to ask better questions using Test::More and sample data

      Note that you will need a utf-8 capable terminal and have the correct locale set in order to view utf-8 data (which the output appears like it might be).

      (updated: added link to test example)

        Ah, that was it. Bit surprised, as that section shouldn't really have any utf8 in it (just plain text)

        Anyway, all I need to do now is look out for what the email encoding is, and if utf8 convert it.

        Thanks!

        Andy

        Mmmm actually, that doesn't work in some cases:

        my $name = "From: =?UTF-8?B?QW5keSBOZXdieSDDrcOpw7M=?= <andy\@cham +bresdhotesfrance.com>"; use MIME::QuotedPrint; if ($name =~ /utf-8|utf8/i) { $name= decode_qp($name); $name =~ s/([\200-\377]+)/from_utf8({ -string => $1, -charset +=> 'ISO-8859-1'})/eg; } print $IN->header; print "NOW: $name";

        Prints out:

        NOW: From: =?UTF-8?B?QW5keSBOZXdieSDDrcOpw7M=?= 
        ...instead of what I was expecting:

        Andy Newby íóé

        This is a valid email header passed through from Thunderbird. Any ideas why it won't decode?

        Cheers

        Andy