Something has gone terribly wrong. Your project is due at noon, and the client just sent you an e-mail attachment containing last-minute revisions. But your Mac can't open the file. Double-clicking on it just brings up an error message. Thinking the file must be corrupted, you frantically phone the client and have him send it again. But the new file still won't open. Desperate, you pry open the manuscript with your word processor, but all you see is page after page of meaningless garbage characters. What's wrong with the file? Probably nothing. You've simply become another victim of MIME.
Let me explain: That string of seemingly meaningless text isn't garbage--it's code. To ensure the attachment's safe passage over the Internet, your client's e-mail program encoded the file using an encryption scheme called MIME (Multipurpose Internet Mail Extensions). MIME turned the file into a string of text characters. Unfortunately, your e-mail program failed to decode the MIME file back into its original format. The good news: you can decode it yourself.
Actually, three types of encoding are routinely used to send attached files via e-mail: MIME, UUencode, and BinHex. All three can potentially leave you with file attachments that look unintelligible. Read on for an explanation of these mysterious codes, why they exist, and how you can crack them open and make your files look the way they are supposed to.
Why It Happened
Most e-mail systems are designed to handle plain-old ASCII characters. These text-based systems use 7 bits of data to specify each character. But many files--such as graphics, databases, and movies--contain a lot more than just plain text. The data packed into such files is stored in a binary format that uses not 7 but 8 bits to define each morsel of information.
So how do you transmit 8-bit data through a 7-bit system? That's where encoding comes in. Encoding schemes use an encryption system that represents each hunk of 8-bit binary data as a string of plain-old ASCII text--text that can travel intact across any file server, through any mail gateway, and into any e-mail program, regardless of platform. When an encoded file arrives at its destination, it's up to your e-mail program to detect the encoding system used and convert the file back into its original binary form--and that's what usually happens, behind the scenes, without your even knowing about it.
However, sometimes the particular encoding system used by the sender isn't supported by the recipient's mail program--there are several different (and incompatible) versions of UUencoding, for example--and the result is that files arrive in their encoded state.
On Mac systems, the most popular encoding scheme is BinHex. UUencoding is an older scheme with Unix origins (the UU stands for Unix-to-Unix). The most popular--and most current--system is MIME, which is also called Base64.
How to Fix It
Fixing a file that arrives in its encoded state is usually a simple drag-and-drop affair. You can assemble a pretty comprehensive decoding kit without spending much money. Use the freeware StuffIt Expander, by Aladdin Systems, to open BinHex files (usually tagged with a .hqx suffix at the end of the file name) and to decompress .sit files. Add the $30 shareware DropStuff with Expander Enhancer to Aladdin's Stuffit Expander, and your decoding/decompressing options multiply: you can handle UUencoded files (usually tagged with a .uu suffix), as well as a number of compression formats, including .zip, .z, .gz, and .ARC files.
If you're willing to assemble an arsenal of smaller, specialized tools, you can spend even less--in fact, nothing--to decode attachments. Open UUencoded, BinHex, and Base64 files with Laurent Hagimont's free utility, uucd. Crack open MIME files with Brian Clark's YA Base64 or John Myers's Mpack--both freeware. Finally, you can use A.P. Maika's freeware UnZip 5.32 to tackle zipped files from PC users. These indispensable utilities are available from Macdownload at Macworld Online.
With most of them, you simply drag the files onto the icon of the appropriate utility to launch the decoding process. For tips on using these utilities, see "Breaking the Code."
How do you determine which utility to use? Usually, a file's name provides a clue. UUencoded files may end with .uu; Base64 files may end with .MIME. Often, though, the suffix is missing; in that case, you have to do some detective work. One easy way to figure out the encoding method used is to open the file in question with a word processor--remember, encoded files are just strings of plain text, and each type of encoding has telltale characteristics (check out "Clues to Decoding").
It may take several rounds of decoding, decompressing, and deciphering to tame the attachments that show up in your in-box, but with a few of the right tools and a little perseverance, you'll never feel victimized by MIME again.
JOSEPH SCHORR is a program manager at Extensis and a coauthor of the forthcoming Macworld Mac Secrets, fifth edition (IDG Books Worldwide).
Breaking the Code
E-mail attachments and downloaded files that arrive encoded and unreadable can usually be decoded and turned back into usable files. Keep these tips in mind when using decoding tools.
If at First You Don't Succeed...
If your decoding efforts fail, don't be too quick to conclude that a file is corrupted; you may be using the wrong decoding tool. There is more than one kind of UUencoding, for example, and a number of MIME variations. If one UUdecoder doesn't work, try another. You may have to run a file through several different utilities that all claim to do the same thing to find one that offers the particular flavor of decoding you require.
Some decoding utilities offer the option of automatically deleting an encoded file after the decoding process--convenient but dangerous. If something goes wrong, you may have to try decoding the file again. Keep original encoded files around until you have a clean, saved copy of the decoded file; then drag the originals to the Trash.
Be a Code Detective
If an attempt to decode a file doesn't work, open the file with your word processor and read the header at the beginning of the code; it will reveal the type of encoding that the sender used.
It's Not Over Till It's Over
Some files are compressed and encoded. You may decode a UUencoded file, for example, only to find that it then has to be decompressed using UnZip.
Don't Count on Double-Clickability
If a file still won't open after you've successfully decoded it, try opening it from within the application that created it, using the Open command. UUencoded files, in particular, tend to lose their type and creator codes in transit and arrive as documents with generic icons. These files won't open with a double-click because the Mac doesn't know what program to use to open them. Opening the files from within the appropriate application solves the problem. (If you don't know what type of file you've got, you'll just have to guess. Keep trying different types of programs till you get one that works.)
Clues to Decoding
Encoded files may look like random garbage, but they contain plenty of clues that reveal how to handle them. The header in the first document reveals that it is a Base64 MIME file. You can tell that the second document is UUencoded because every line starts with the letter M. BinHex files, like the third document, always contain a line at the top that says the file must be converted with BinHex.