#
-# $Id: Base64.pm,v 2.16 2001/02/24 06:28:10 gisle Exp $
+# $Id: Base64.pm,v 2.19 2002/12/28 06:32:37 gisle Exp $
package MIME::Base64;
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(encode_base64 decode_base64);
-$VERSION = '2.12';
+$VERSION = '2.13';
eval { bootstrap MIME::Base64 $VERSION; };
if ($@) {
sub old_encode_base64 ($;$)
{
- my $res = "";
my $eol = $_[1];
$eol = "\n" unless defined $eol;
- pos($_[0]) = 0; # ensure start at the beginning
- $res = join '', map( pack('u',$_)=~ /^.(\S*)/, ($_[0]=~/(.{1,45})/gs));
+ my $res = pack("u", $_[0]);
+ # Remove first character of each line, remove newlines
+ $res =~ s/^.//mg;
+ $res =~ s/\n//g;
$res =~ tr|` -_|AA-Za-z0-9+/|; # `# help emacs
# fix padding at the end
$str =~ s/=+$//; # remove padding
$str =~ tr|A-Za-z0-9+/| -_|; # convert to uuencoded format
- return join'', map( unpack("u", chr(32 + length($_)*3/4) . $_),
- $str =~ /(.{1,60})/gs);
+ ## I guess this could be written as
+ #return unpack("u", join('', map( chr(32 + length($_)*3/4) . $_,
+ # $str =~ /(.{1,60})/gs) ) );
+ ## but I do not like that...
+ my $uustr = '';
+ my ($i, $l);
+ $l = length($str) - 60;
+ for ($i = 0; $i <= $l; $i += 60) {
+ $uustr .= "M" . substr($str, $i, 60);
+ }
+ $str = substr($str, $i);
+ # and any leftover chars
+ if ($str ne "") {
+ $uustr .= chr(32 + length($str)*3/4) . $str;
+ }
+ return unpack ("u", $uustr);
}
# Set up aliases so that these functions also can be called as
+2002-02-27 Gisle Aas <gisle@ActiveState.com>
+
+ Release 2.13
+
+ Sync up with bleadperl:
+ - Documentation update
+ - EBCDIC support
+ - Whitespace tweaks
+ - Improved Unicode support
+ - Test suite tweaks
+
+ Improved version of the old_{en,de}code_base64 functions
+ contributed by Paul Szabo <psz@maths.usyd.edu.au>.
+
+
+
2001-02-23 Gisle Aas <gisle@ActiveState.com>
Release 2.12
#
-# $Id: QuotedPrint.pm,v 2.3 1997/12/02 10:24:27 aas Exp $
+# $Id: QuotedPrint.pm,v 2.4 2002/12/28 05:50:05 gisle Exp $
package MIME::QuotedPrint;
use Carp qw(croak);
-$VERSION = sprintf("%d.%02d", q$Revision: 2.3 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.4 $ =~ /(\d+)\.(\d+)/);
sub encode_qp ($)
{
my $res = shift;
- croak("The Quoted-Printable encoding is only defined for bytes")
- if $res =~ /[^\0-\xFF]/;
+ if ($] >= 5.006) {
+ require bytes;
+ if (bytes::length($res) > length($res) ||
+ ($] >= 5.008 && $res =~ /[^\0-\xFF]/)) {
+ croak("The Quoted-Printable encoding is only defined for bytes");
+ }
+ }
# Do not mention ranges such as $res =~ s/([^ \t\n!-<>-~])/sprintf("=%02X", ord($1))/eg;
# since that will not even compile on an EBCDIC machine (where ord('!') > ord('<')).