Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: [ANNOUNCE] vdr-wapd-0.0.1 pre-release



Jan Ekholm wrote:

On Thu, 3 Jun 2004, Jan Ekholm wrote:

as a response. Anyone have any links to a simple base64 implementation?
I've looked for one in the past, and I haven't found one. Writing one
isn't really that interesting. :)
I'm a Perl guy : http://search.cpan.org/~gaas/MIME-Base64-3.00/Base64.pm
This package contains both a Perl and a C implementation.

The Perl code is below :

sub old_decode_base64 ($)
{
    local($^W) = 0; # unpack("u",...) gives bogus warning in 5.00[123]

    my $str = shift;
    $str =~ tr|A-Za-z0-9+=/||cd;            # remove non-base64 chars
    if (length($str) % 4) {
    require Carp;
    Carp::carp("Length of base64 data not a multiple of 4")
    }
    $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);
}

NH





Home | Main Index | Thread Index