HP-UX Reference (11i v3 07/02) - 1 User Commands N-Z (vol 2)
u
uuencode(1) uuencode(1)
13 N 30 e 47 v
14 O 31 f 48 w (pad) =
15 P 32 g 49 x
16 Q 33 h 50 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 char-
acters 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 stan-
dard 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 com-
bined with the most significant bits of the second octet shifted right. Thus the three octets A, B, C are con-
verted 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 algo-
rithm) with xyz as the intended name on the remote system and saves the output in outfile:
HP-UX 11i Version 3: February 2007 − 2 − Hewlett-Packard Company 375