CPC Binary Barcode
CPC Binary Barcode is Canada Post's proprietary symbology used in its automated mail sortation operations. This barcode is used on regular-size pieces of mail, especially mail sent using Canada Post's Lettermail service. This barcode is printed on the lower-right-hand corner of each faced envelope, using a unique ultraviolet-fluorescent ink. Symbology description
The applied barcode uses printed and non-printed bars spaced 3 mm apart, and consists of two fields. The rightmost field, which is 27 bars in width, encodes the destination postal code. The leftmost field is 9 bars in width and applied right below the printed destination address. It is currently unclear what this field is used for. In the postal code field, the rightmost bar is always printed, to allow the sortation equipment to properly lock onto the barcode and scan it. The leftmost bar, a parity field, is printed only when necessary to give the postal code field an odd number of printed bars. The remaining 25 bars represent the actual destination postal code. To eliminate any possibility of ambiguity during the scanning process, run-length restrictions are used within the postal code field. No more than five consecutive non-printed bars, or spaces, are permitted, and no more than six consecutive printed bars are allowed. The actual representation of the postal code is split into four subfields of the barcode, each with their own separate encoding table. The first and last subfields, which share a common encoding table, are always eight bars in width, and encode the first two characters and the last two characters of the postal code respectively. The second subfield, which encodes the third character of the postal code, is always five bars in width, and the third subfield, which encodes the fourth character, is always four bars wide. Generating barcodes
Disregarding the space, divide the postal code into four subfields (e.g. K1-A-0-B1). Locate the contents of each subfield in the encoding tables below and record the hexadecimal numbers that they correspond to. (e.g. K1-A-0-B1 becomes 32-07-A-C2.) Convert those hex numbers to binary, and add leading zeroes where required. Change the binary numbers into bars. "Zero" bits in the resulting binary numbers correspond to spaces in the barcode, while "one" bits correspond to printed bars, with the least significant bit of each number corresponding to the rightmost bar in each subfield of the barcode. Add an "alignment" bar onto the end of the resulting barcode. Count up the number of bars you have. If you get an even number, add another bar onto the start of the barcode. Here are some examples of encoded postal codes. The colour used in these examples is meant to simulate the actual colour of the ink used to print the barcodes, however it does not exactly match. Select these examples to make them more visible. A1B 2C3: | |||  |  ||  |  || ||  |||
K1A 0B1: |  ||  |   |||| | ||    | |
V6B 2R5: |   | ||  ||  |  | | | | ||

Encoding tables
Note that postal codes use only 20 letters; six letters (D, F, I, O, Q, U) are never used. Unused codepoints are indicated with dashes. No field begins or ends with more than three consecutive 1 bits, guaranteeing that there are never more than six consecutive 1 bits. Guaranteeing the five-bit limit on consecutive 0 bits is achieved by limiting the boundaries of the second and fourth fields to three consecutive 0 bits, and the first and third fields to two consecutive 0 bits:
 No field contains more than five consecutive 0 bits. Code 81, which would contain six consecutive 0 bits in field 1 or 4, is not used. Field 1 never ends in more than two consecutive 0 bits. Codes that end in three or more consecutive 0 bits encode the letters Z or W, which are not used for the first letter of postal codes. Field 2 may begin or end with at most three consecutive 0 bits. Field 3 never begins with more than two consecutive 0 bits, nor does it ever end with more than one. Field 4 may begin with up to three consecutive 0 bits, and may end with up to five consecutive 0 bits, but is always followed by a 1 bit (the alignment bar). Barcodes
Canada Post