1UUENCODE(1P)               POSIX Programmer's Manual              UUENCODE(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       uuencode - encode a binary file
13

SYNOPSIS

15       uuencode [-m][file] decode_pathname
16

DESCRIPTION

18       The uuencode utility shall write an encoded version of the named  input
19       file,  or  standard  input if no file is specified, to standard output.
20       The output shall be encoded using one of the  algorithms  described  in
21       the  STDOUT  section  and shall include the file access permission bits
22       (in chmod octal or  symbolic  notation)  of  the  input  file  and  the
23       decode_pathname,  for  re-creation  of  the file on another system that
24       conforms to this volume of IEEE Std 1003.1-2001.
25

OPTIONS

27       The uuencode utility shall conform to the Base  Definitions  volume  of
28       IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
29
30       The following option shall be supported by the implementation:
31
32       -m     Encode  the  output using the MIME Base64 algorithm described in
33              STDOUT.  If  -m  is  not  specified,  the  historical  algorithm
34              described in STDOUT shall be used.
35
36

OPERANDS

38       The following operands shall be supported:
39
40       decode_pathname
41
42              The  pathname  of the file into which the uudecode utility shall
43              place the decoded file. Specifying a decode_pathname operand  of
44              /dev/stdout shall indicate that uudecode is to use standard out‐
45              put. If there are characters in decode_pathname that are not  in
46              the portable filename character set the results are unspecified.
47
48       file   A pathname of the file to be encoded.
49
50

STDIN

52       See the INPUT FILES section.
53

INPUT FILES

55       Input files can be files of any type.
56

ENVIRONMENT VARIABLES

58       The following environment variables shall affect the execution of uuen‐
59       code:
60
61       LANG   Provide a default value for the  internationalization  variables
62              that  are  unset  or  null.  (See the Base Definitions volume of
63              IEEE Std 1003.1-2001, Section  8.2,  Internationalization  Vari‐
64              ables  for the precedence of internationalization variables used
65              to determine the values of locale categories.)
66
67       LC_ALL If set to a non-empty string value, override the values  of  all
68              the other internationalization variables.
69
70       LC_CTYPE
71              Determine  the  locale  for  the  interpretation of sequences of
72              bytes of text data as characters (for  example,  single-byte  as
73              opposed to multi-byte characters in arguments and input files).
74
75       LC_MESSAGES
76              Determine  the  locale  that should be used to affect the format
77              and contents of diagnostic messages written to standard error.
78
79       NLSPATH
80              Determine the location of message catalogs for the processing of
81              LC_MESSAGES .
82
83

ASYNCHRONOUS EVENTS

85       Default.
86

STDOUT

88   uuencode Base64 Algorithm
89       The  standard output shall be a text file (encoded in the character set
90       of the current locale) that begins with the line:
91
92
93              "begin-base64 %s %s\n", <mode>, <decode_pathname>
94
95       and ends with the line:
96
97
98              "====\n"
99
100       In both cases, the lines shall have no preceding or trailing <blank>s.
101
102       The encoding process represents 24-bit groups of input bits  as  output
103       strings  of  four  encoded characters. Proceeding from left to right, a
104       24-bit input group shall be formed by concatenating three  8-bit  input
105       groups.  Each 24-bit input group then shall be treated as four concate‐
106       nated 6-bit groups, each of which shall be  translated  into  a  single
107       digit in the Base64 alphabet. When encoding a bit stream via the Base64
108       encoding, the bit stream shall be presumed to be ordered with the most-
109       significant  bit  first.  That is, the first bit in the stream shall be
110       the high-order bit in the first byte, and the eighth bit shall  be  the
111       low-order bit in the first byte, and so on. Each 6-bit group is used as
112       an index into an array of 64 printable characters, as shown in uuencode
113       Base64 Values .
114
115                            Table: uuencode Base64 Values
116
117          Value Encoding Value Encoding Value Encoding Value Encoding
118          0     A        17    R        34    i        51    z
119          1     B        18    S        35    j        52    0
120          2     C        19    T        36    k        53    1
121          3     D        20    U        37    l        54    2
122          4     E        21    V        38    m        55    3
123          5     F        22    W        39    n        56    4
124          6     G        23    X        40    o        57    5
125          7     H        24    Y        41    p        58    6
126          8     I        25    Z        42    q        59    7
127          9     J        26    a        43    r        60    8
128          10    K        27    b        44    s        61    9
129          11    L        28    c        45    t        62    +
130          12    M        29    d        46    u        63    /
131          13    N        30    e        47    v
132
133          14    O        31    f        48    w        (pad)──────────
134          15    P        32    g        49    x
135          16    Q        33    h        50    y
136
137       The  character  referenced  by  the index shall be placed in the output
138       string.
139
140       The output stream (encoded bytes) shall be represented in lines  of  no
141       more  than  76 characters each. All line breaks or other characters not
142       found in the table shall be ignored by decoding software (see  uudecode
143       ).
144
145       Special  processing shall be performed if fewer than 24 bits are avail‐
146       able at the end of a message or encapsulated part of a message. A  full
147       encoding  quantum  shall  always  be completed at the end of a message.
148       When fewer than 24 input bits are available in  an  input  group,  zero
149       bits  shall be added (on the right) to form an integral number of 6-bit
150       groups. Output character positions that are not required  to  represent
151       actual  input data shall be set to the character '=' . Since all Base64
152       input is an integral number of octets, only  the  following  cases  can
153       arise:
154
155        1. The  final  quantum of encoding input is an integral multiple of 24
156           bits; here, the final unit of encoded output shall be  an  integral
157           multiple of 4 characters with no '=' padding.
158
159        2. The  final  quantum of encoding input is exactly 16 bits; here, the
160           final unit of encoded output shall be three characters followed  by
161           one '=' padding character.
162
163        3. The  final  quantum  of encoding input is exactly 8 bits; here, the
164           final unit of encoded output shall be two  characters  followed  by
165           two '=' padding characters.
166
167       A  terminating  "===="  evaluates to nothing and denotes the end of the
168       encoded data.
169
170   uuencode Historical Algorithm
171       The standard output shall be a text file (encoded in the character  set
172       of the current locale) that begins with the line:
173
174
175              "begin %s %s\n" <mode>, <decode_pathname>
176
177       and ends with the line:
178
179
180              "end\n"
181
182       In both cases, the lines shall have no preceding or trailing <blank>s.
183
184       The  algorithm  that  shall  be used for lines in between begin and end
185       takes three octets as input and writes four  characters  of  output  by
186       splitting  the  input at six-bit intervals into four octets, containing
187       data in the lower six bits only.  These octets shall  be  converted  to
188       characters  by adding a value of 0x20 to each octet, so that each octet
189       is in the range [0x20,0x5f], and then it shall be assumed to  represent
190       a  printable character in the ISO/IEC 646:1991 standard encoded charac‐
191       ter set. It then shall be translated into the  corresponding  character
192       codes  for the codeset in use in the current locale.  (For example, the
193       octet 0x41, representing 'A', would be translated to 'A' in the current
194       codeset, such as 0xc1 if it were EBCDIC.)
195
196       Where  the  bits of two octets are combined, the least significant bits
197       of the first octet shall be shifted left and  combined  with  the  most
198       significant  bits  of  the  second  octet shifted right. Thus the three
199       octets A, B, C shall be converted into the four octets:
200
201
202              0x20 + (( A >> 2                    ) & 0x3F)
203              0x20 + (((A << 4) | ((B >> 4) & 0xF)) & 0x3F)
204              0x20 + (((B << 2) | ((C >> 6) & 0x3)) & 0x3F)
205              0x20 + (( C                         ) & 0x3F)
206
207       These octets then shall be translated into the local character set.
208
209       Each encoded line contains a length character, equal to the  number  of
210       characters  to  be  decoded plus 0x20 translated to the local character
211       set as described above, followed by the encoded characters.  The  maxi‐
212       mum number of octets to be encoded on each line shall be 45.
213

STDERR

215       The standard error shall be used only for diagnostic messages.
216

OUTPUT FILES

218       None.
219

EXTENDED DESCRIPTION

221       None.
222

EXIT STATUS

224       The following exit values shall be returned:
225
226        0     Successful completion.
227
228       >0     An error occurred.
229
230

CONSEQUENCES OF ERRORS

232       Default.
233
234       The following sections are informative.
235

APPLICATION USAGE

237       The file is expanded by 35 percent (each three octets become four, plus
238       control information) causing it to take longer to transmit.
239
240       Since this utility is intended to create files  to  be  used  for  data
241       interchange  between  systems  with possibly different codesets, and to
242       represent binary data as a text file, the ISO/IEC 646:1991 standard was
243       chosen  for a midpoint in the algorithm as a known reference point. The
244       output from uuencode is a text file on the local system. If the  output
245       were  in  the ISO/IEC 646:1991 standard codeset, it might not be a text
246       file (at least because the <newline>s might not match), and the goal of
247       creating a text file would be defeated. If this text file was then car‐
248       ried to another machine with the same codeset, it  would  be  perfectly
249       compatible  with  that  system's uudecode. If it was transmitted over a
250       mail system or sent to a  machine  with  a  different  codeset,  it  is
251       assumed  that, as for every other text file, some translation mechanism
252       would convert it (by the time it reached a user on  the  other  system)
253       into an appropriate codeset. This translation only makes sense from the
254       local codeset, not if the file has been  put  into  a  ISO/IEC 646:1991
255       standard  representation  first. Similarly, files processed by uuencode
256       can be placed in pax archives, intermixed with other text files in  the
257       same codeset.
258

EXAMPLES

260       None.
261

RATIONALE

263       A new algorithm was added at the request of the international community
264       to parallel work in RFC 2045 (MIME). As with  the  historical  uuencode
265       format,  the  Base64 Content-Transfer-Encoding is designed to represent
266       arbitrary sequences of octets in a form that is not humanly readable. A
267       65-character  subset of the ISO/IEC 646:1991 standard is used, enabling
268       6 bits to be represented per printable character. (The extra 65th char‐
269       acter, '=', is used to signify a special processing function.)
270
271       This  subset  has the important property that it is represented identi‐
272       cally in all versions of the ISO/IEC 646:1991  standard,  including  US
273       ASCII,  and  all  characters in the subset are also represented identi‐
274       cally in all versions of EBCDIC. The historical uuencode algorithm does
275       not  share  this  property, which is the reason that a second algorithm
276       was added to the ISO POSIX-2 standard.
277
278       The string "====" was used for the termination instead of the end  used
279       in  the  original  format  because the latter is a string that could be
280       valid encoded input.
281
282       In an early draft, the -m option was named -b (for Base64), but it  was
283       renamed  to  reflect  its  relationship  to the RFC 2045. A -u was also
284       present to invoke the default algorithm, but since this was not histor‐
285       ical practice, it was omitted as being unnecessary.
286
287       See  the  RATIONALE  section  in  uudecode  for  the  derivation of the
288       /dev/stdout symbol.
289

FUTURE DIRECTIONS

291       None.
292

SEE ALSO

294       chmod(), mailx, uudecode
295
297       Portions of this text are reprinted and reproduced in  electronic  form
298       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
299       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
300       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
301       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
302       event of any discrepancy between this version and the original IEEE and
303       The Open Group Standard, the original IEEE and The Open Group  Standard
304       is  the  referee document. The original Standard can be obtained online
305       at http://www.opengroup.org/unix/online.html .
306
307
308
309IEEE/The Open Group                  2003                         UUENCODE(1P)
Impressum