Xref: utzoo comp.sys.atari.st:8907 comp.sys.mac:14874 Path: utzoo!mnetor!uunet!husc6!necntc!ima!think!ephraim From: ephraim@think.COM (ephraim vishniac) Newsgroups: comp.sys.atari.st,comp.sys.mac Subject: Re: binHex in atari ST Message-ID: <19093@think.UUCP> Date: 7 Apr 88 18:34:36 GMT References: <1537@alliant.Alliant.COM> <1505@water.waterloo.edu> Sender: usenet@think.UUCP Reply-To: ephraim@vidar.think.com.UUCP (ephraim vishniac) Organization: Thinking Machines Corporation, Cambridge, MA Lines: 54 Summary: There's source code on sumex-aim In article <1505@water.waterloo.edu> ljdickey@water.waterloo.edu (Lee Dickey) writes: >There are probably many who use BinHex or UU{en,de}CODE without >without knowing what they do, and there are probably others who do not >know about the existence of the "other" encoding function. > >BinHex is an easy enough program to write. > >Its purpose is to turn a binary file into something that has only >printable characters, so that it can be e-mailed over networks >that might respond to control characters, and, perhaps, >( cough, gasp ) be read! > >Each OCTET ( 8 bit byte ) of the binary file is split into two nibbles, >4 bits each. Each nibble is used as a pointer to index into the vector >"0123456789ABCDEF" with 16 elements. Thus, for each byte of the binary >file, you get two hexadecimal characters. The result is a file with >twice as many characters as the original file. Some people have become >experts at reading this stuff. Their heads have 16 sides. They will >become telephone sanitizers. :-) Originally (i.e., about fall of 1984), this was a correct description of BinHex (.HEX) format. Since then, the name of the program has stayed the same, but the format of the encoded file has changed repeatedly, first to .HCX (compressed BinHex) and then to .HQX (BinHex 4.0). For ASCII-encoding purposes, the format stabilized with BinHex 4.0 in 1985. BinHex 4.0: (1) uses 64 ASCII graphic characters so as to encode six bits of useful data in each 8-bit byte. (2) uses run-length compression to reduce the size of the encoded representation. (3) calculates a CRC-16 to check file integrity. (4) represents the directory information, data, and resource forks of a Mac file in a single encoded block. So, it's just a tad more complicated than Lee's posting suggested :-). For code to decode BinHex files, get a copy of xbin.c (for Unix) from sumex-aim. There's also a program there for creating BinHex 4.0 files on a Unix system, but it doesn't perform compression. I've also read comments to the effect that it's an awful hack. Looking in my copy of the directory at sumex, I see files called BINHEX4.BAS, BINHEX4.PAS, and BINHEX4-SOURCE-ASSEMBLY.HQX. The first two are dated July '85; the last is dated June '87. These look like promising places to start... Ephraim Vishniac ephraim@think.com Thinking Machines Corporation / 245 First Street / Cambridge, MA 02142-1214 On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?"