CPC Binary Barcode

From Wikipedia, the free encyclopedia
Jump to: navigation, search

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[edit]

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[edit]

  1. Disregarding the space, divide the postal code into four subfields (e.g. K1-A-0-B1).
  2. 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.)
  3. Convert those hex numbers to binary, and add leading zeroes where required.
  4. 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.
  5. Add an "alignment" bar onto the end of the resulting barcode.
  6. 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[edit]

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.

First and fourth fields (8 bits)
 00: ––   01: ––   02: ––   03: ––   04: ––   05: ––   06: ––   07: ––   08: ––   09: ––   0A: ––   0B: ––   0C: ––   0D: ––   0E: ––   0F: –– 
10: –– 11: X0 12: V1 13: V3 14: X1 15: V5 16: V6 17: V7 18: –– 19: V2 1A: V0 1B: V4 1C: X2 1D: V8 1E: V9 1F: ––
20: Z1 21: N1 22: L1 23: L3 24: T1 25: L5 26: L6 27: L7 28: W1 29: L2 2A: L0 2B: L4 2C: P1 2D: L8 2E: L9 2F: ––
30: Z3 31: N3 32: K1 33: K3 34: T3 35: K5 36: K6 37: K7 38: W3 39: K2 3A: K0 3B: K4 3C: P3 3D: K8 3E: K9 3F: ––
40: –– 41: X3 42: M1 43: M3 44: X4 45: M5 46: M6 47: M7 48: –– 49: M2 4A: M0 4B: M4 4C: X5 4D: M8 4E: M9 4F: ––
50: Z5 51: N5 52: R1 53: R3 54: T5 55: R5 56: R6 57: R7 58: W5 59: R2 5A: R0 5B: R4 5C: P5 5D: R8 5E: R9 5F: ––
60: Z6 61: N6 62: J1 63: J3 64: T6 65: J5 66: J6 67: J7 68: W6 69: J2 6A: J0 6B: J4 6C: P6 6D: J8 6E: J9 6F: ––
70: Z7 71: N7 72: A1 73: A3 74: T7 75: A5 76: A6 77: A7 78: W7 79: A2 7A: A0 7B: A4 7C: P7 7D: A8 7E: A9 7F: ––
80: –– 81: –– 82: H1 83: H3 84: X9 85: H5 86: H6 87: H7 88: –– 89: H2 8A: H0 8B: H4 8C: –– 8D: H8 8E: H9 8F: ––
90: Z2 91: N2 92: G1 93: G3 94: T2 95: G5 96: G6 97: G7 98: W2 99: G2 9A: G0 9B: G4 9C: P2 9D: G8 9E: G9 9F: ––
A0: Z0 A1: N0 A2: S1 A3: S3 A4: T0 A5: S5 A6: S6 A7: S7 A8: W0 A9: S2 AA: S0 AB: S4 AC: P0 AD: S8 AE: S9 AF: ––
B0: Z4 B1: N4 B2: C1 B3: C3 B4: T4 B5: C5 B6: C6 B7: C7 B8: W4 B9: C2 BA: C0 BB: C4 BC: P4 BD: C8 BE: C9 BF: ––
C0: –– C1: X6 C2: B1 C3: B3 C4: X7 C5: B5 C6: B6 C7: B7 C8: –– C9: B2 CA: B0 CB: B4 CC: X8 CD: B8 CE: B9 CF: ––
D0: Z8 D1: N8 D2: E1 D3: E3 D4: T8 D5: E5 D6: E6 D7: E7 D8: W8 D9: E2 DA: E0 DB: E4 DC: P8 DD: E8 DE: E9 DF: ––
E0: Z9 E1: N9 E2: Y1 E3: Y3 E4: T9 E5: Y5 E6: Y6 E7: Y7 E8: W9 E9: Y2 EA: Y0 EB: Y4 EC: P9 ED: Y8 EE: Y9 EF: ––
F0: –– F1: –– F2: –– F3: –– F4: –– F5: –– F6: –– F7: –– F8: –– F9: –– FA: –– FB: –– FC: –– FD: –– FE: –– FF: ––
Second field (5 bits) Third field (4 bits)
00: 01: 02: L 03: K 04: M 05: R 06: J 07: A 0: 1: 2: 1 3: 3
08: H 09: G 0A: S 0B: C 0C: B 0D: E 0E: Y 0F: 4: 5: 5 6: 6 7: 7
10: 11: V 12: 13: X 14: T 15: 16: N 17: 8: 9: 2 A: 0 B: 4
18: W 19: 1A: Z 1B: 1C: P 1D: 1E: 1F: C: D: 8 E: 9 F:

No field begins or ends with more than 3 consecutive 1 bits, guaranteeing that there are never more than 6 consecutive 1 bits. Guaranteeing the 5-bit limit on consecutive 0 bits is achieved by limiting the boundaries of the second and fourth fields to 3 consecutive 0 bits, and the first and third fields to 2 consecutive 0 bits:

  • No field contains more than 5 consecutive 0 bits. Code 81, which would contain 6 consecutive 0 bits in field 1 or 4, is not used.
  • Field 1 never ends in more than 2 consecutive 0 bits. Codes that end in 3 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 3 consecutive 0 bits.
  • Field 3 never begins with more than 2 consecutive 0 bits, nor does it ever end with more than 1.
  • Field 4 may begin with up to 3 consecutive 0 bits, and may end with up to 5 consecutive 0 bits, but is always followed by a 1 bit (the alignment bar).