#!/usr/bin/perl -W # vim:fileencoding=utf-8 # PuTTY option: Remote character set = UTF-8 # my locale: en_US.UTF-8 (LANG and all LC_* except LC_ALL="") use warnings; use strict; use utf8; use MIME::Lite; use MIME::Base64; my $m = MIME::Lite->new(To => 'a@example.com', From => 'b@example.net', Subject => 'Test', Type => 'TEXT', # Perlmonks safe encoding with same result Data => "Not latin: \x{30ab}\x{30bf}\x{30ab}\x{30ca}\n"); my $s = $m->as_string; print "UTF-8 flag: ", utf8::is_utf8($s), "\n"; binmode(STDOUT, ':raw'); print $s; # warns: wide char in print print encode_base64($s); # dies: wide char in sub entry