Skip Menu |

This queue is for tickets about the MIME-Lite CPAN distribution.

Report information
The Basics
Id: 25168
Status: resolved
Priority: 0/
Queue: MIME-Lite

People
Owner: Nobody in particular
Requestors: adrian.m.smith [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: UTF-8 and unicode data with MIME::Lite
Date: Tue, 27 Feb 2007 08:45:07 +0100
To: bug-MIME-Lite [...] rt.cpan.org
From: "Adrian Smith" <adrian.m.smith [...] gmail.com>
Hello, I think MIME::Lite predates Perl 5.8 which supports Unicode and UTF-8. But it's easy to get MIME::Lite to work with Unicode bodies and subjects. To attach a plain text part to a message, with a string which contains unicode characters, use: $msg->attach( Type => 'text/plain; charset=UTF-8', Data => encode("utf8", $utf8string), ); To set the subject of a mail from a string containing unicode characters, use: use MIME::Base64; my $msg = MIME::Lite->new( ... Subject => "=?UTF-8?B?" . encode_base64(encode("utf8", $subj), "") . "?=", ... ); Note that the above methods also work even if the strings do not contain unicode characters, or do not have the UTF-8 bit set. It would be better to change MIME::Lite such that subject and data strings are accepted and the above code happens inside MIME::Lite. Cheers, Adrian -- adrian //at// smith-software-development-macau.com http://www.smith-software-development-macau.com/
Unfortunately, there is no really good mechanism for determining whether a string is a character string or byte string. Things should be kept explicit. I am not excited about changing the long-long-standing API, either. While I might accept a comprehensive and well-tested patch, this is probably a non-starter. -- rjbs