Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > U

uuencode(1)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

uuencode, uudecode — encode/decode a binary file for transmission by mailer

SYNOPSIS

uuencode [-m] [source_file] remotedest

uudecode [-o outfile] [encoded_file]

DESCRIPTION

uuencode and uudecode can be used to send a binary file to another machine by means of such services as elm, mailx, or uucp (see elm(1), mailx(1), and uucp(1)).

uuencode takes the named source file (default standard input) and produces an encoded version on the standard output. The encoding uses only printing ASCII characters, includes the original mode of the input file, and preserves the value of the remotedest argument which is the intended name of the file when it is restored later on the remote system.

uudecode reads an encoded file (the encoded_file argument), ignores any leading and trailing lines added by mailers, and recreates the original file with the specified mode and name.

The encoded file is an ordinary ASCII text file and can be edited with any text editor to change the mode or remote name.

Options and Arguments

uuencode recognizes the following command-line option:

-m

Encode the input file using the MIME Base64 algorithm. If -m is not specified, the historical algorithm encodes the input.

uudecode recognizes the following command-line option and argument:

-o outfile

Specifies the pathname of the file that holds the decoded output. This file is not the same as remotedest which was specified at the time of encoding the file.

uuencode Base64 Algorithm

The encoded file is a text file, encoded in the character set of the current locale (the portable character set). The file begins with the line:

begin-base64 mode remotedest

and ends with the line:

====\n

Both of the above lines have no preceding or trailing blank characters.

The encoding process represents each 24-bit group of input bits as output strings of four encoded characters. Proceeding from left to right, each 24-bit input group is formed by concatenating three 8-bit input groups. Each such 24-bit input group is then treated as four concatenated 6-bit groups, each of which would be translated into a single digit in the Base64 alphabet shown in the following table.

Value EncodingValue EncodingValue EncodingValue Encoding
0 A17 R34 i51 z
1 B18 S35 j52 0
2 C19 T36 k53 1
3 D20 U37 l54 2
4 E21 V38 m55 3
5 F22 W39 n56 4
6 G23 X40 o57 5
7 H24 Y41 p58 6
8 I25 Z42 q59 7
9 J26 a43 r60 8
10 K27 b44 s61 9
11 L28 c45 t62 +
12 M29 d46 u63 /
13 N30 e47 v 
14 O31 f48 w(pad) =
15 P32 g49 x 
16 Q33 h50 y 

When encoding a bit stream via 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 shall be the high-order bit in the first byte, and the eighth bit shall be the low-order bit in the first byte, and so on.

Each line of the encoded output can have only 76 characters or less. If there are less than 24 bits available at the end of a message or encapsulated part of a message, zero bits are added (on the right) to form an integral number of 6-bit groups. Output character positions that are completely made of the padded zero bits are set to the equal character (=).

Because all Base64 input is an integral number of octets, only the following cases can arise at the end of an input bit stream:

1.

If the final quantum of encoding input is an integral multiple of 24 bits, the final unit of encoded output is an integral multiple of 4 characters with no '=' padding character.

2.

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

3.

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

All line breaks and other non-Base64 characters are ignored by uudecode. A terminating evaluates to nothing and denotes the end of the encoded data.

uuencode Historical Algorithm

The encoded file is a text file, encoded in the character set of the current locale (the portable character set). It begins with the line:

begin mode remotedest

and ends with the line:

end\n

Both of the above lines have no preceding or trailing blank characters.

This algorithm takes three octets as input and writes four characters of output by splitting the input at 6-bit intervals. The four 6-bit groups make four octets each of which contain 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]. That is, it is assumed to represent a printable character in the ISO/IEC 646:1991 standard encoded character set. Each octet is then translated into the corresponding character code for the codeset in use in the current locale before writing the encoded output.

When 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 following four octets:

0x20 + (( A >> 2 ) & 0x3F)
0x20 + (((A << 4) | ((B >> 4) & 0xF)) & 0x3F)
0x20 + (((B << 2) | ((C >> 6) & 0x3)) & 0x3F)
0x20 + (( C ) & 0x3F)

These octets are then translated into the local character set.

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. Each line of the encoded output has only 45 characters or less.

EXAMPLES

The following example encodes a file abc (using the historical algorithm) with xyz as the intended name on the remote system and saves the output in outfile:

uuencode abc xyz > outfile

Similarly, the following example uses the -m option to encode a file abc (using the MIME Base64 algorithm) with xyz as the intended name on the remote system and saves the output in outfile:

uuencode -m abc xyz > outfile

The following example shows how to encode and send a compiled program foo to user friend:

uuencode foo foo | mailx -s new_program friend

After receiving the mail message, user friend can decode the program to a file with the same name as the original file by first saving the message in a file foo.mail and executing the command:

uudecode foo.mail

Similarly, the user friend can also decode the program to a file named foo.output by first saving the message in a file foo.mail and executing the command:

uudecode -o foo.output foo.mail

WARNINGS

The file is expanded by 35% (three bytes become four plus control information) causing it to take longer to transmit.

The user on the remote system who is invoking uudecode (often uucp) must have write permission for the specified file.

If an encoded file has the same name as the destination name specified in it, uudecode starts overwriting the encoded file before decoding is completed.

STANDARDS CONFORMANCE

uuencode,uudecode: XPG4, POSIX.2

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.