Newsgroups: alt.snail-mail From: lachman@netcom.com (Hans Lachman) Subject: How to read bar codes. Date: Tue, 31 Aug 1993 00:51:15 GMT This is my contribution to the future Snail Mail FAQ. Ever wonder how the Snail Mail bar codes are encoded? Since the bar codes are a combination of short and long bars, you might think it's just binary. Well, sort of. Each decimal digit of the ZIP code is encoded as a 5-bit binary word, as follows: 0: ||... 5: .|.|. 1: ...|| 6: .||.. 2: ..|.| 7: |...| 3: ..||. 8: |..|. 4: .|..| 9: |.|.. Each word must have two (and only two) "ones" and three "zeroes". The values of the bit positions are: ..... 74210 The exeption is "0" which is encoded as "||...". A complete bar code contains 5, 9, or 11 5-bit words, depending on whether it encodes a 5, 9, or 11 digit ZIP code; plus another 5-bit word, to encode an extra digit that is used as a check digit; plus an extra "|" at each end. So you would encode "90210" as: ||.|..||.....|.|...||||...|..|.| |<-9-><-0-><-2-><-1-><-0-><-8->| The way the check digit works is that, when you add up all the digits (including the check digit), you should get a multiple of 10 (e.g., 9+0+2+1+0+8 = 20). The construction of a bar code printer/reader is left as an exercise to the entrepreneur. Hans Lachman lachman@netcom.com