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

In reply to MIME::Lite::TT::Html - issues with umlauts by Skeeve

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.