The discussion in this thread made me realize that I'd better update my
own mail related module, CGI::ContactForm, as regards MIME encoding. An
updated version has been uploaded to CPAN.
http://search.cpan.org/dist/CGI-ContactForm/
On February 24, 2009 Octavian Râsnita wrote:
Mail::Sender doesn't encode the headers to UTF-8 and we would need to do
that MIME encoding explicitly which is something I wouldn't like.
It's not that difficult. The key code I used in CGI::ContactForm is a
function named mimeencode(). This code illustrates how a header is being
prepared before it's passed to Mail::Sender:
use MIME::QuotedPrint;
my $subject = 'Smörgåsbord';
$subject = mimeencode($subject, 'UTF-8');
print "$subject\n";
sub mimeencode {
my ($str, $enc) = @_;
return $str unless $str =~ /[[:^ascii:]]/;
my @parts;
while ( $str =~ /(.{1,40}.*?(?:\s|$))/g ) {
my $part = $1;
push @parts, MIME::QuotedPrint::encode($part, '');
}
join "\r\n\t", map { "=?$enc?Q?$_?=" } @parts;
}
The resulting output is:
=?UTF-8?Q?Sm=C3=B6rg=C3=A5sbord?=
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/