[MKDoc-commit] [Petal-Mail] added binmode (SENDMAIL, ":utf8");
to force utf-8 output
bruno at mkdoc.demon.co.uk
bruno at mkdoc.demon.co.uk
Wed Mar 16 16:18:30 GMT 2005
Log Message:
-----------
[Petal-Mail] added binmode (SENDMAIL, ":utf8"); to force utf-8 output
Modified Files:
--------------
Petal-Mail:
Changes
Petal-Mail/lib/Petal:
Mail.pm
Added Files:
-----------
Petal-Mail/t:
003_unicode.t
Petal-Mail/t/data:
news.xml
-------------- next part --------------
Index: Changes
===================================================================
RCS file: /var/spool/cvs/Petal-Mail/Changes,v
retrieving revision 1.4
retrieving revision 1.5
diff -LChanges -LChanges -u -r1.4 -r1.5
--- Changes
+++ Changes
@@ -1,6 +1,8 @@
Revision history for Petal::Mail.
-0.31
+0.31 Wed Mar 16 2005
+ - added binmode (SENDMAIL, ":utf8"); to force utf-8 output
+ - removed defunct email address
0.3 Fri Jan 16 2004
- repeated tests with input and output set to 'HTML'
Index: Mail.pm
===================================================================
RCS file: /var/spool/cvs/Petal-Mail/lib/Petal/Mail.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -Llib/Petal/Mail.pm -Llib/Petal/Mail.pm -u -r1.4 -r1.5
--- lib/Petal/Mail.pm
+++ lib/Petal/Mail.pm
@@ -145,6 +145,7 @@
my $mail = $self->process (%args) || die '$self->process (\@_) returned undef';
open (SENDMAIL, "| $Sendmail -f $authorized_sender") || die "error opening sendmail [$Sendmail]: $!";
+ binmode (SENDMAIL, ":utf8");
print SENDMAIL $mail || die "error writing to sendmail [$Sendmail]: $!";
close SENDMAIL;
}
--- /dev/null
+++ t/003_unicode.t
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More 'no_plan';
+use lib ('lib', '../lib');
+use Petal::Mail;
+
+my $string;
+my $formatter = new Petal::Mail (
+ base_dir => [ './t/data', './data' ],
+ file => 'news.xml'
+);
+
+my $euro = "\x{20ac}";
+my $copy = "\x{00a9}";
+my $club = "\x{2663}";
+my $spade = "\x{2660}";
+
+my $text = "Euro: $euro Copy: $copy Club: $club Spade: $spade";
+
+my $data = {from_name => "The Queen of $spade\'s",
+ from_email => "queen\@spades.example.com",
+ to_name => "The king of $club\'s",
+ to_email => "king\@clubs.example.com",
+ subject => "Test message: $text",
+ joined => "Test message: $text"};
+
+$string = $formatter->process ( $data );
+
+like ($string, qr /From: =\?UTF-8\?B\?VGhlIFF1ZWVuIG9mIOKZoA==\?='s <queen\@spades\.example\.com>/);
+like ($string, qr /X-Copyright: =\?UTF-8\?B\?Q29weXJpZ2h0IMKpIDIwMDUgTUtEb2MgTHRk\?=\./);
+
+like ($string, qr /To: =\?UTF-8\?B\?VGhlIGtpbmcgb2Yg4pmj\?='s <king\@clubs\.example\.com>/);
+like ($string, qr /Subject: Test message: Euro:=\?UTF-8\?B\?IOKCrCBDb3B5\?=:=\?UTF-8\?B\?IMKpIENsdWI=\?=:/);
+
+like ($string, qr /Dear The king of $club\'s/);
+like ($string, qr /$euro/);
+like ($string, qr /$copy/);
+like ($string, qr /$club/);
+like ($string, qr /$spade/);
+
+1;
+
+
+__END__
--- /dev/null
+++ t/data/news.xml
@@ -0,0 +1,30 @@
+<Message
+ xmlns="http://www.openhealth.org/xmtp#"
+ xmlns:petal="http://purl.org/petal/1.0/"
+ >
+ <Content-Type>text/plain; charset=utf-8; format=flowed</Content-Type>
+ <Content-Disposition>inline</Content-Disposition>
+ <Content-Transfer-Encoding>8bit</Content-Transfer-Encoding>
+ <X-Copyright>Copyright © 2005 MKDoc Ltd.</X-Copyright>
+ <Content-Language>en</Content-Language>
+ <MIME-Version>1.0</MIME-Version>
+
+ <From petal:content="string:${from_name} <${from_email}>">News team <newsletter at example.com></From>
+ <To petal:content="string:${to_name} <${to_email}>">Fred Flintstone <fred.flintstone at example.com></To>
+ <Subject
+ petal:content="string:${subject}"
+ >MKDoc Daily Email Update</Subject>
+
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <p>
+ Dear <span petal:replace="string:${to_name}">Fred Flintstone</span>,
+ </p>
+
+ <p>
+ Here are some unicode characters: <span petal:content="string:${joined}">ascii</span>
+ </p>
+ <pre>
+ Here are some more unicode characters: $joined
+ </pre>
+ </body>
+</Message>
More information about the MKDoc-commit
mailing list