Bug#879204: [rt.cpan.org #123341] Re: Bug#879205: MIME::Words::encode_mimewords: double-encodes (produces Mojibake), produces too long lines

Dianne Skoll dfs at roaringpenguin.com
Fri Oct 20 20:37:35 UTC 2017


Hi,

This is not a bug in MIME::tools.

The OP misunderstands how Perl works.  He typed UTF-8 source code in and
is double encoding it.  Here's a test program:

#===================================================================
use MIME::Words;
use Encode;

my $sample = "Re: Bildungsurlaub für CCC-Fahrt? [THD#1424195]";

my $utf8 = Encode::encode('UTF-8', $sample);
my $out = MIME::Words::encode_mimewords($utf8, Charset => 'UTF-8');

print "Out: $out\n";
#===================================================================

If I run:

   perl test-utf8.pl

Output is:

   Out: Re: Bildungsurlaub =?UTF-8?Q?f=C3=83=C2=BCr=20?=CCC-Fahrt? [THD#1424195]

But that's because the word "für" is *already* UTF-8.  If I tell Perl
to convert UTF-8 in the source code to native Perl Unicode, the result
is very different:

  perl -Mutf8 test-utf8.pl

Output is:

  Out: Re: Bildungsurlaub =?UTF-8?Q?f=C3=BCr=20?=CCC-Fahrt? [THD#1424195]

The OP should read "perldoc utf8" and should also not use UTF-8 directly
as Perl source code; use \x{FC} rather than ü, etc.

Regards,

Dianne.



More information about the pkg-perl-maintainers mailing list