in reply to MIME::Lite::TT::Html - issues with umlauts

The first thing which springs into my eye is the line: Encode::_utf8_on($params{umlaut}); It is almost always just plain wrong to use this function (and the documentation contains sufficient warnings). I guess that it is an attempt to fix your issue, but it is the wrong way. So I'll start by just deleting this line.

The next thing you need to care about is the encoding in which your Perl source is stored. It contains literal äöu, and your source code editor will decide (or take hints from you) whether it stores it as UTF-8 or something like ISO-LATIN-1. If your editor saves as UTF-8, you need to inform the interpreter about this by including the following line in your source code: use utf8;

For the moment I'll assume that your source file is encoded in ISO-LATIN-1, because there's more.

The documentation of MIME::Lite::TT::HTML tells us that it has two options which are missing from your source code:

So this is my version of the source code, which I saved in ISO-LATIN-1-encoding:

#!/usr/bin/env perl use strict; use warnings; use MIME::Lite::TT::HTML; 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', }, Charset => 'utf8', Encoding => '8bit', TmplOptions => \%options, TmplParams => \%params, ); binmode STDOUT, ':utf8'; print "Should be: ", $params{umlaut},$/; print '-' x 79,$/; print $msg->as_string;

And on a contemporary Linux console (which means: it expects UTF-8 encoding), the output looks like this:

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

Note that both headers Content-Transfer-Encoding and Content-Type are now correct.

Replies are listed 'Best First'.
Re^2: MIME::Lite::TT::Html - issues with umlauts
by Skeeve (Parson) on Feb 04, 2020 at 12:58 UTC

    Thanks a lot to both of you. It works.


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