in reply to base64 encoding
sub old_encode_base64 ($;$) { my $res = ""; my $eol = $_[1]; $eol = "\n" unless defined $eol; pos($_[0]) = 0; # ensure start at the beg +inning $res = join '', map( pack('u',$_)=~ /^.(\S*)/, ($_[0]=~/(.{1,45})/ +gs)); $res =~ tr|` -_|AA-Za-z0-9+/|; # `# help emacs # fix padding at the end my $padding = (3 - length($_[0]) % 3) % 3; $res =~ s/.{$padding}$/'=' x $padding/e if $padding; # break encoded string into lines of no more than 76 characters ea +ch if (length $eol) { $res =~ s/(.{1,76})/$1$eol/g; } return $res; }
-- Dan
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (z) Re: base64 encoding
by spike_hodge (Novice) on Feb 27, 2003 at 08:42 UTC | |
by zigdon (Deacon) on Feb 27, 2003 at 14:10 UTC |