uuencode and uudecode

Object files, image files and compressed files contain many non-printing non-ASCII characters. (These are null bytes and bytes with the high-order bit set.)

Such files cannot be directly included into an e-mail message. (Many mail programs will discard non-printing characters or convert them into other characters. Indeed many mail programs will do bad things to a text line which starts with a period, and a period is certainly a printing character!)

The uuencode program converts any file into a file that contains only printing characters (and no line in the result begins with a period either). It is, of course, a reversible operation. The uudecode program undoes the conversion.

Note that uuencoding makes a file larger. The result is about 35% larger than the original.

Sending a Binary File by E-Mail

Suppose that we wish to e-mail the MyProject.tar.Z file to someone. We can execute the command:
	  uuencode MyProject.tar.Z MyProject.tar.Z > MyProject.tar.Z.uu
The first argument to uuencode is the file we wish to encode. The second argument is the name to attach to the recovered file when the receiver executes the uudecode command. The name is usually the same as the original file.

The final product is a file named MyProject.tar.Z.uu -- the .uu suffix is commonly used to indicate a uuencoded file.

The sender can now send the compressed archive file using a command like this:

	mail -s 'My project file' joe@saturn.utu.fi < MyProject.tar.Z.uu 
The string after the -s flag is used as a Subject line in the e-mail message.

Receiving a Uuencoded File

The recipient of an e-mailed uuencoded file should save the entire e-mail message in a file -- let's call this file message.

To retrieve the original file, the recipient executes:

		uudecode message 
This will cause a new file named MyProject.tar.Z to appear in the current directory. Now the recipient can run uncompress and tar to extract all the constituent files from the archive file.

Mime Encoding or Base64 Encoding

An alternative to uuencode is become common with e-mail (especially e-mail sent from PCs). This alternative is called base64 encoding and is one of the MIME standard formats for mail encoding. On some Unix systems (not our Alpha machine yet), there is a program named mmencode (or mimencode) which performs translation to or from the base64 format.

Please refer to the Unix man pages for usage information.