Uuencode

NAME

Util::Uuencode - uuencode/uudecode for Raku

SYNOPSIS

use Util::Uuencode;
my $image = "some-image.jpg".IO.slurp(:bin);
my $encoded = uuencode($image);
# now $encoded can be sent or stored as text safely
$image = uudecode($encoded);
# now have the image back as binary

DESCRIPTION

uuencode is a binary to text encoding mechanism designed for sending binary files across computer boundaries where the transport mechanism may not be 8 bit clean, such as e-mail, usenet or uucp. It has largely been obsoleted by MIME (and Base64 encoding,) and the advent of ubiquitous 8 bit clean networking.

This module provides routines for uuencoding (uuencode) and decoding (uudecode) which will round trip data between binary and text encoded representations. uuencode will quite happily encode plain text but as the effect is to make it a third larger there isn't much point doing that ( I guess at a push it could be used to preserve some unicode encoding across some boundary that doesn't deal with that well.)

The POSIX commands uuencode and uudecode expect some additional header and trailer information which this module doesn't deal with, so if you expect your data to be processed by these tools you will need to add this to your encoded output and remove it from the input for correct processing.

uuencode

multi sub uuencode(Str $in, Bool :$strict = False --> Str)
    multi sub uuencode(buf8 $in, Bool :$strict = False --> Str)

This takes the data to be encoded and returns the encoded text representation, if the input data is a Blob other than a buf8 (Buf[uint8]) you will need to coerce it as appropriate before passing it.

By default this uses the modified encoding, that appears to be used by the majority of implementations, whereby the backtick ("`", ASCII 96) replaces space ( " ", ASCII 32) in the encoded output. If you need to interoperate with code that strictly implements the POSIX description then you should supply the :strict adverb to the call.

uudecode

sub uudecode(Str $in --> buf8)

This takes the uuencoded text as produced by uuencode and returns the original data as a buf8. If you are expecting Str data then you will need to call .decode on the buf8.

As noted above this will only deal with the encoded block of text and the begin and end lines from output generated by the classic uuencode command will need to be removed prior to calling this.

This will deal with either the strict or de-facto encoding as described in uuencode.

Util::Uuencode v0.0.3

uuencode and uudecode for raku

Authors

  • Jonathan Stowe

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • Util::Uuencode

Documentation

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.