Huntsville Macintosh Users Group
Encoding and Decoding Files
Documents | MacNews | News | Podcasts | Presentations | Reviews | Tips | User Groups | Site Index
by J.J. Weimer

Files that you send over the internet often have to be encoded or decoded. This means, they have to be converted from one coding format to another. The two diametrically opposed formats for encoding and decoding are ASCII text and binary. The difference in these two formats has to do with how a character byte (a letter) is represented.

First, recall that a byte of information in computer language is eight bits of information. Each bit is either a 0 (zero) or 1 (one). After some further conversions are done (binary arithmetic), one byte with a bit pattern 00000000 is a value of zero, whereas one byte with a bit pattern 11111111 is a value of 255. This tells us that a range of values from 0 to 255 can be represented in one byte. This is, by the way, what is meant by saying we use eight bits of color or grayscale information - we can have up to 256 colors or levels of gray.

In ASCII text files, every character is coded by only seven bits of information. The eighth bit is ignored (it can be a zero or one). The letter A (capital A) could for example be represented by the bit pattern 01000001 OR 11000001 (in true ASCII files, the eighth bit is always zero, so the pattern 01000001 is capital A). Files that contain information coded in all eight bits are called binary files. In binary files, the value of the eighth bit (zero or one) is very important. For example, in a binary graphics file, the bit patterns 01000001 and 11000001 represent two completely different colors or shades of color. If we thought these bytes were ASCII encoded, we would always get only the 01000001 bit pattern in the file, and the colors would be scrambled accordingly when we viewed the picture. Some graphics files (JPEG) use all eight bits of a byte to provide information. Others (GIF) use only seven bits.

E-mail is purely an ASCII text transfer method. When you send an attachment via e-mail, it must be an ASCII text file. Binary files (such as graphics) that you want to send via e-mail have to be encoded from eight bits binary to seven bits ASCII before being sent included as attachments. They then have to be decoded by the person who receives them, that is they are converted from seven bit ASCII back to eight bit binary. This encoding and decoding has nothing to do with the program that is used to view the graphics file, it has to do with sending the file over the internet via e-mail.

Various encoding/decoding schemes exist to send binary files as ASCII files. On a Mac, the most famous is BinHex. Another is MacBinary (in versions II or III). In the real world (outside of the Mac platform), the most widely used encoding is MIME (standing for Message Internet Mail Encoding or Mostly Internet Message Encoding or Maybe Its MIME Encoded or ????). You will often see MIME encoding associated with setting your Web browser to handle different file types.

You must have the appropriate decoder to decode a file that has been encoded. Some e-mail programs do not support all the different encoders, therefore you have to have additional applications to do the job. If you receive an attachment file that is MIME encoded, and your e-mail program does not know how to decode the file, you will have to get the decoder and run it on the file you have received. This should convert the ASCII file back to a binary file that you can then read or view.

Fortunately, getting the appropriate decoder program is not as difficult as it sounds. You do not have to belong to a society with secret handshakes and quietly whispered passwords. All you need to do is look in the Macintosh archives of software, typically under Compression or Archiving, for different encoders and decoders. They are typically freeware or shareware utilities. For BinHex, the program BinHex will do the job. For MIME, MPack is one recommend application.

As a final note, you can also put a binary file into an archive before sending it with e-mail. This will automatically convert the binary format to ASCII format as well as compressing the file to smaller size. On the Mac, the most widely used archive format is StuffIt (from Aladdin Systems). StuffIt is now also available for WinXX platforms, so your buddies working with the evil empire have no excuse not to be able to handle a SIT or SEA archive if you send it to them. On the PC side, the most widely used archiving format is ZIP. You can download freeware or shareware utilities to uncompress ZIP formatted files. By comparison, on Unix, the common archiving format is TAR.

By the way, the program StuffIt Deluxe for the Mac will handle all types of file formats and encodings (ZIP, TAR, SIT/SEA, uuencode, MIME, ...)

Version 1.1.0 - 20070310
User Group Logo