Hamilton LaboratoriesHamilton C shell 2012User guideExternal utilities


Oregon Coast

Previous | Next

        Uudecode Binary Data

Usage:  uudecode [-h-] [ file1 file2 ... ]

   Uuencode and Uudecode are used to encode arbitrary binary
   data into a sequence consisting solely of printable ASCII
   characters, thus allowing the data to be sent over mail
   systems, etc., that cannot handle binary data.

   Uuencode reads from the source file (or stdin if no source
   file is specified), writing the encoded version to stdout.

   Uudecode reads the encoded file (or stdin), strips off any
   leading and trailing lines and recreates the original file,
   giving it the name that had been specified to uuencode as
   the decode_pathname parameter.

Uuencode format:

   The encoded form consists of a header line followed by a
   number of body lines and a trailer line.  The header is
   of the form:

       begin <mode> <decode_pathname>

   where the <mode> field indicates the read/write permissions
   to be given to the file.  The file ends with a line of the


   Both these lines shall have no preceding or trailing
   text or white space.

   The POSIX standard specifies that the "end" line should
   be the only indicator of the end of data.  Most existing
   uudecode implementations do not adhere to this specification,
   however.  Instead, they require that there be an immediately
   preceding line marked as containing 0 bytes of data.  To
   ensure compatibility with these flawed uudecodes, this
   uuencode/uudecode pair will write that dummy line when
   encoding and ignore it when decoding.

   Data is encoded three bytes at a time into four printable
   ASCII characters by splitting the input at 6 bit intervals
   into 4 bytes, each containing data in only the lower 6 bits.
   The hex value 0x20 is then added to each byte, producing
   a value in the range 0x20 to 0x5f, which are all printable
   ASCII characters.  Thus, three bytes A, B and C of raw data
   are converted to the four ASCII characters:

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

   The encoded data is arranged into lines of no more than
   60 characters (representing at most 45 bytes of raw data)
   preceded by a length character, equal to the number of
   raw characters encoded plus 0x20.

   Some existing uuencode implementations do not correctly
   follow this specification.  If the resulting character
   is a space, they'll write a backquote instead.  Their
   decoding procedure is to extract only the low 7 bits
   after subtracting 0x20.  This extra step is, fortunately,
   innocuous on correctly encoded data, so for compatibility
   with existing uuencodes, this version of uudecode performs
   that mask operation also.

   Although not required by the POSIX standard, this version
   of uudecode has a number of enhancements:

   1.  It will accept input streams containing any number of
       uuencoded files concatenated together.  Each will be
       properly extracted as a separate file.

   2.  If any directory levels in the output are missing,
       an attempt will be made to create them.

   3.  The tilde is recognized as a home directory reference
       in the decode pathname.


   -h           Help.  (This screen.)
   --           End of options.

Previous | Next