Synopsis

Description

These commands encode and decode files as follows:

uuencode

The uuencode utility converts a binary file into an encoded representation that
can be sent using mail(1). It encodes the contents of source-file, or
the standard input if no source-file argument is given. The decode_pathname argument
is required. The decode_pathname is included in the encoded file's header
as the name of the file into which uudecode is to place
the binary (decoded) data. uuencode also includes the permission modes of source-file
(except setuid, setgid, and sticky-bits), so that decode_pathname is recreated with those
same permission modes.

uudecode

The uudecode utility reads an encoded-file, strips off any leading and trailing
lines added by mailer programs, and recreates the original binary data with
the filename and the mode specified in the header.

The encoded file is an ordinary portable character set text file; it
can be edited by any text editor. It is best only to
change the mode or decode_pathname in the header to avoid corrupting
the decoded binary.

Options

The following options are supported:

uuencode

-m

Encodes source-file using Base64 encoding and sends it to standard output.

uudecode

-ooutfile

Specifies a file pathname that should be used instead of any pathname contained in the input data. Specifying an outfile option-argument of /dev/stdout indicates standard output.This allows uudecode to be used in a pipeline.

-p

Decodes encoded-file and sends it to standard output. This allows uudecode to be used in a pipeline.

Operands

The following operands are supported by uuencode and uudecode:

uuencode

decode_pathname

The pathname of the file into which the uudecode utility will place the decoded file. If there are characters in decode_pathname that are not in the portable filename character set, the results are unspecified.

source-file

A pathname of the file to be encoded.

uudecode

encoded-file

The pathname of a file containing the output of uuencode.

Usage

See largefile(5) for the description of the behavior of uuencode and uudecode
when encountering files greater than or equal to 2 Gbyte ( 231
bytes).

Environment Variables

See environ(5) for descriptions of the following environment variables that affect the
execution of uuencode and uudecode: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, and NLSPATH.

OUTPUT

stdout

uuencode Base64 Algorithm

The standard output is a text file, encoded in the character set
of the current locale, that begins with the line:

begin-base64 %s %s\
, mode, decode_pathname

and ends with the line:

====\

In both cases, the lines have no preceding or trailing blank characters.

The encoding process represents 24-bit groups of input bits as output strings
of four encoded characters. Proceeding from left to right, a 24-bit
input group is formed by concatenating three 8-bit input groups. Each 24-bit
input group is then treated as four concatenated 6-bit groups, each
of which is translated into a single digit in the Base64 alphabet.
When encoding a bit stream by means of the Base64 encoding, the
bit stream is presumed to be ordered with the most-significant bit first. That
is, the first bit in the stream is the high-order bit in
the first byte, and the eighth bit is the low-order bit in
the first byte, and so on. Each 6-bit group is used as
an index into an array of 64 printable characters, as shown in
the following table.

The output stream (encoded bytes) is represented in lines of no more
than 76 characters each. All line breaks or other characters not found
in the table are ignored by decoding software (see uudecode).

Special processing is performed if fewer than 24 bits are available at
the end of a message or encapsulated part of a message. A
full encoding quantum is always completed at the end of a message.
When fewer than 24 input bits are available in an input group,
zero bits are added on the right to form an integral number
of 6-bit groups. Output character positions that are not required to represent
actual input data are set to the equals (=) character. Since all
Base64 input is an integral number of octets, only the following cases can
arise:

The final quantum of encoding input is an integral multiple of 24 bits. Here, the final unit of encoded output is an integral multiple of four characters with no '= ' padding.

The final quantum of encoding input is exactly 16 bits. Here, the final unit of encoded output is three characters followed by one '=' padding character.

The final quantum of encoding input is exactly 8 bits. Here, the final unit of encoded output is two characters followed by two '=' padding characters.

A terminating "====" evaluates to nothing and denotes the end of the
encoded data.

uuencode Historical Algorithm

The standard output is a text file (encoded in the character set
of the current locale) that begins with the line:

begin %s %s\n, mode, decode_pathname

and ends with the line:

end\n

In both cases, the lines have no preceding or trailing blank characters.

The algorithm that is used for lines between begin and end takes
three octets as input and writes four characters of output by splitting
the input at six-bit intervals into four octets, containing data in the
lower six bits only. These octets are converted to characters by adding
a value of 0x20 to each octet, so that each octet is
in the range 0x20-0x5f, and each octet is assumed to represent a
printable character. Each octect is then translated into the corresponding character codes for
the codeset in use in the current locale. For example, the octet
0x41, representing 'A', would be translated to 'A' in the current codeset,
such as 0xc1 if the codeset were EBCDIC.

Where the bits of two octets are combined, the least significant bits
of the first octet are shifted left and combined with the most
significant bits of the second octet shifted right. Thus, the three octets
A, B, C are converted into the four octets:

Each encoded line contains a length character, equal to the number of
characters to be decoded plus 0x20 translated to the local character set
as described above, followed by the encoded characters. The maximum number of
octets to be encoded on each line is 45.