BinHex Format

Summary: The BinHex format. What is this standard? Why do some programs use it? How to decode the files? How to transfer such files to a Macintosh medium?
 

Introduction

The BinHex format was created to satisfy two specific needs. First, to allow transferring binary files (therefore coded on 8 bits) sent on the Internet, whose pipes are not always "8-bit clean". This means that there must be some sort of mapping between a 8-bit stream and a 7-bit stream. Secondly, to bundle in a single container both forks composing a Macintosh file. Last but not the least, the author, Yves Lempereur, added a compression function, of the RLE type, to avoid sending repetitive sequences of identical characters.

How to identify a binhexed file?

The suffix used for binhexed files is generally HQX. The signature of those files (on a HFS or HFS+ [Macintosh] medium) is TEXTBNHQ.
More, the first line of a BinHex file is:

(This file must be converted with BinHex 4.0)

You only have to open the file in a word processor to ascertain that the file you received is indeed a BinHex file. Please note that this comment line is not mandatory, according to the specs, but that all utilities we already used put this line at the beginning of the file. The BinHex standard also specifies that the first and last character of the data stream should be a colon (:).
Most classical binhexed files only have this first comment line, followed by a carriage return and a line feed (and only one pair of those). However, we already saw files where this line was not the first one, but the second one. We also saw files where the end-of-line marker (which should be a carriage return + line feed) was only the carriage return, or only the line feed, or both, but in the reverse order.
Our programs were amended to also handle correctly such files. Upgrade

When can you get binhexed files?

The BinHex standard is one of the working modes (with Mime) of most Macintosh mail softwares. Those packages code and decode the data stream automatically, and most users never know they are using binhexed files. Things are different when a Macintosh user sends a file to a PC user. Some mail packages on the PC don't know the BinHex standard and just store the coded file on the hard disk.
The BinHex format is also used by some programs to build Macintosh files on other platforms. That is what Flash (Macromedia) does when asked to build a Macintosh animation. In this case, the BinHex coding plays the same role than the MacBinary coding, since the 7-bit coding is technically irrelevant.

How to decode binhexed files on the PC?

There are several utilities to decode binhexed files on the PC. They generally show some shortcomings, mostly because of the very nature of Macintosh files. The main shortcomings are:

Managing BinHex Files in MacDisk and MacImage

When you select a BinHex file to copy it to a hardware Macintosh medium (with MacDisk) or to include it in a Macintosh CD-ROM project (with MacImage), those programs know how to identify the file and therefore propose the user to open and unpack the file (the container) to put all pieces where they belong and get the original file back.
The operations are almost transparent.
A demo/trial version (with limited copy features) can be downloaded from this Web site.

MacMail

You may wish to visit our page on MacMail, a new utility aimed at managing all kinds of Macintosh attached files sent by e-mail. This program offers a broader range of features (identifying, converting, adding correct suffixes/extensions, etc.), and can in particular monitor a folder for new files, which can be handy if you get many attached files in your e-mail box.
A demo/trial version (working for a limited time period) can be downloaded from this Web site

DeBinHex

To solve those problems, we also developped a specific utility.
Our program DeBinHex answers the needs outlined above. It allows the user to know what is in a binhexed file without having to decode it first (Macintosh real name, file signature, size of the data fork, size of the resource fork). Then, it allows the user to decode the file (of course!). Several working modes are offered: decoding of the data fork alone, of the resource fork alone or of both forks, and conversion to MacBinary. This mode can be useful if you want to reinstall a Macintosh file on a Macintosh medium, which would be necessary to execute a program, for an example.
This utility can be downloaded from this site.
It is free for a personal, non-professional use and for users of other products from our software range.
Professional users and companies should send an e-mail to know the licensing conditions.

To Go Further

There is a good article on the Binhex standard in the Wikipedia.
The Binhex format was mostly used around the Mac but its origins go much further. See this page on the Prehistory of Binhex.

 
Logiciels & Services Duhem
3, rue Pierre Haret - F-75009 Paris (France) - Tel. (+33) [0]149 700 455 - SIRET 381 149 996 00047 - EEC VAT FR32 381 149 996
email: sales (at) macdisk.com — web: http://www.macdisk.com