Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

r22882@knight: rjbs | 2006-07-04 07:19:15 -0400

 import from mailclue cvs
  • Loading branch information...
commit ea4f721bac35c89e94e948c32d0e6141b0483b7a 0 parents
@rjbs authored
16 Changes
@@ -0,0 +1,16 @@
+Revision history for Perl extension Email::MIME::Encodings.
+
+1.3 2004-10-22
+
+ - Dependencies changed output formats. Thanks to many for
+ reporting but thanks to Nick Clark for finding the actual
+ problem.
+
+1.2 2004-09-25
+
+ - Dependency fixes, author fixes.
+
+0.01 Thu Apr 10 15:00:16 2003
+ - original version; created by h2xs 1.2 with options
+ -AX -n Email::MIME::Encodings
+
83 Encodings.pm
@@ -0,0 +1,83 @@
+package Email::MIME::Encodings;
+use strict;
+no strict 'refs';
+use warnings;
+
+$Email::MIME::Encodings::VERSION = "1.3";
+
+use MIME::Base64;
+use MIME::QuotedPrint;
+
+sub identity { $_[0] }
+
+for (qw(7bit 8bit binary)) {
+ *{"encode_$_"} = *{"decode_$_"} = \&identity;
+}
+
+sub codec {
+ my ($which, $how, $what) = @_;
+ $how = lc $how;
+ $how = "qp" if $how eq "quotedprint" or $how eq "quoted-printable";
+ my $sub = $which."_".$how;
+ if (not defined &$sub) {
+ require Carp;
+ Carp::croak("Don't know how to $which $how");
+ }
+ $sub->($what);
+}
+
+sub decode { return codec("decode", @_) }
+sub encode { return codec("encode", @_) }
+
+1;
+
+=head1 NAME
+
+Email::MIME::Encodings - A unified interface to MIME encoding and decoding
+
+=head1 SYNOPSIS
+
+ use Email::MIME::Encodings;
+ my $encoded = Email::MIME::Encodings::encode(base64 => $body);
+ my $decoded = Email::MIME::Encodings::decode(base64 => $encoded);
+
+=head1 DESCRIPTION
+
+This module simply wraps C<MIME::Base64> and C<MIME::QuotedPrint>
+so that you can throw the contents of a C<Content-Transfer-Encoding>
+header at some text and have the right thing happen.
+
+=head1 AUTHOR
+
+Simon Cozens, C<simon@cpan.org>
+
+=head1 SUPPORT
+
+Beep... beep... this is a recorded announcement:
+
+I've released this software because I find it useful, and I hope you
+might too. But I am a being of finite time and I'd like to spend more of
+it writing cool modules like this and less of it answering email, so
+please excuse me if the support isn't as great as you'd like.
+
+Nevertheless, there is a general discussion list for users of all my
+modules, to be found at
+http://lists.netthink.co.uk/listinfo/module-mayhem
+
+If you have a problem with this module, someone there will probably have
+it too.
+
+=head1 SEE ALSO
+
+C<MIME::Base64>, C<MIME::QuotedPrint>, C<Email::MIME>.
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2004, Casey West F<<casey@geeknest.com>>.
+
+Copyright 2003 by Simon Cozens
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
7 MANIFEST
@@ -0,0 +1,7 @@
+Changes
+Encodings.pm
+Makefile.PL
+MANIFEST This list of files
+META.yml
+README
+test.pl
12 META.yml
@@ -0,0 +1,12 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: Email-MIME-Encodings
+version: 1.3
+version_from: Encodings.pm
+installdirs: site
+requires:
+ MIME::Base64: 3.05
+ MIME::QuotedPrint: 3.03
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17
11 Makefile.PL
@@ -0,0 +1,11 @@
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+ 'NAME' => 'Email::MIME::Encodings',
+ 'VERSION_FROM' => 'Encodings.pm', # finds $VERSION
+ PREREQ_PM => {
+ 'MIME::Base64' => '3.05',
+ 'MIME::QuotedPrint' => '3.03',
+ },
+);
43 README
@@ -0,0 +1,43 @@
+NAME
+ Email::MIME::Encodings - A unified interface to MIME encoding and
+ decoding
+
+SYNOPSIS
+ use Email::MIME::Encodings;
+ my $encoded = Email::MIME::Encodings::encode(base64 => $body);
+ my $decoded = Email::MIME::Encodings::decode(base64 => $encoded);
+
+DESCRIPTION
+ This module simply wraps "MIME::Base64" and "MIME::QuotedPrint" so that
+ you can throw the contents of a "Content-Transfer-Encoding" header at
+ some text and have the right thing happen.
+
+AUTHOR
+ Simon Cozens, "simon@cpan.org"
+
+SUPPORT
+ Beep... beep... this is a recorded announcement:
+
+ I've released this software because I find it useful, and I hope you
+ might too. But I am a being of finite time and I'd like to spend more of
+ it writing cool modules like this and less of it answering email, so
+ please excuse me if the support isn't as great as you'd like.
+
+ Nevertheless, there is a general discussion list for users of all my
+ modules, to be found at
+ http://lists.netthink.co.uk/listinfo/module-mayhem
+
+ If you have a problem with this module, someone there will probably have
+ it too.
+
+SEE ALSO
+ "MIME::Base64", "MIME::QuotedPrint", "Email::MIME".
+
+COPYRIGHT AND LICENSE
+ Copyright 2004, Casey West <casey@geeknest.com>.
+
+ Copyright 2003 by Simon Cozens
+
+ This library is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself.
+
22 test.pl
@@ -0,0 +1,22 @@
+use Test::More tests => 12;
+use_ok("Email::MIME::Encodings");
+
+my $x = "This is a test\nof various MIME=stuff.";
+for (qw(binary 7bit 8bit)) {
+ is(Email::MIME::Encodings::encode($_, $x), $x, "enc $_");
+ is(Email::MIME::Encodings::decode($_, $x), $x, "dec $_");
+}
+
+$y= "This is a test\nof various MIME=3Dstuff.=\n";
+is(Email::MIME::Encodings::encode(quotedprint => $x), $y, "enc qp");
+is(Email::MIME::Encodings::decode(quotedprint => $y), $x, "dec qp");
+
+$z="VGhpcyBpcyBhIHRlc3QKb2YgdmFyaW91cyBNSU1FPXN0dWZmLg==\n";
+is(Email::MIME::Encodings::encode(base64 => $x), $z, "enc 64");
+is(Email::MIME::Encodings::decode(base64 => $z), $x, "dec 64");
+
+eval {
+ Email::MIME::Encodings::encode(foo => $x);
+};
+
+like ($@, qr/how to encode foo/, "Error handling");
Please sign in to comment.
Something went wrong with that request. Please try again.