http://qs321.pair.com?node_id=11112352

Skeeve has asked for the wisdom of the Perl Monks concerning the following question:

Dear fellow monks,

I have an issue with MIME::Lite::TT::Html in that it does not properly handle umlauts (UTF-8 in general).

This is my sample code:

#!/usr/bin/env perl use strict; use warnings; use MIME::Lite::TT::HTML; use Encode; my %params; $params{umlaut} = 'fööbär'; Encode::_utf8_on($params{umlaut}); my %options= ( INCLUDE_PATH => '.', ENCODING => 'UTF-8', ); my $msg = MIME::Lite::TT::HTML->new( From => 'admin@example.com', To => 'frank@example.com', Subject => 'Your recent purchase', Template => { text => 'revsys.txt.tt', html => 'revsys.html.tt', }, TmplOptions => \%options, TmplParams => \%params, ); binmode STDOUT, ':utf8'; print "Should be: ", $params{umlaut},$/; print '-' x 79,$/; print $msg->as_string;

And these are the templates:

revsys.txt.tt: text: [% umlaut %] revsys.html.tt: <h1>[% umlaut %]</h1>

The output is:

Should be: fööbär ---------------------------------------------------------------------- +--------- Content-Transfer-Encoding: binary Content-Type: multipart/alternative; boundary="_----------=_1580806618 +90" MIME-Version: 1.0 X-Mailer: MIME::Lite 3.031 (F2.85; T2.17; A2.21; B3.15; Q3.13) Subject: =?US-ASCII?B?WW91ciByZWNlbnQgcHVyY2hhc2U=?= Date: Tue, 4 Feb 2020 08:56:58 +0000 To: frank@example.com From: admin@example.com This is a multi-part message in MIME format. --_----------=_158080661890 Content-Disposition: inline Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii text: fbr --_----------=_158080661890 Content-Disposition: inline Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii <h1>fbr</h1> --_----------=_158080661890--

As you can see: The Template output is just "fbr" and should be "fööbär".

Any advice? Did I do something wrong? Are there alternatives I should consider which can handle UTF-8?


s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e