Skip to content

Australia Post, the postal code that repairs what it reads - #234

Merged
s2x merged 1 commit into
v2from
v2-australia-post
Sep 3, 2026
Merged

Australia Post, the postal code that repairs what it reads#234
s2x merged 1 commit into
v2from
v2-australia-post

Conversation

@s2x

@s2x s2x commented Sep 3, 2026

Copy link
Copy Markdown
Member

The twenty-ninth generator, and the last of the four-state postal codes.

australia-post (aliases auspost, australia-post-4state, customer-barcode), pure PHP, one option.

What it is

An eight-digit sorting code — the Delivery Point Identifier — optionally followed by a customer information field. After Intelligent Mail the layout reads like a relief: start bars, Format Control Code, sorting code, customer field, parity, stop bars, every field at a fixed offset.

What it spends instead is the parity. It is the only postal code here that corrects: four Reed–Solomon codewords over GF(64), repairing two of them. Encoding\ReedSolomonGf2m already spoke that field for Aztec and MaxiCode, so this reused rather than grew. It is also why the bars group in threes — three bars are six bits are one codeword — and why the Standard Customer Barcode is thirty-seven bars rather than thirty-six: one filler bar exists so the count divides.

Two decisions

The Format Control Code is an option. Six codes exist. Three are what the article is — Reply Paid, Routing, Redirection — and nothing in the data says which was meant. The other three (11, 59, 62) are not a choice: they follow from the width of the customer field, so Payload picks them.

A half-filled customer field is refused, not padded. The field is sized in bars rather than characters, which is why the lengths look arbitrary and are not: 5 or 10 characters, or 8 or 15 digits. Padding a shorter one would mean inventing semantics no reader has agreed to — filler bars in the middle of a C-table field index as lower-case letters — and zint will not draw such a symbol for comparison either.

Both character tables are derived rather than transcribed. They turned out to be one enumeration read at two widths: combinations with no tracker bar first in ascending order, then those with a tracker in the leading bar, then the leftovers.

Verification

  • 527 symbols bar for bar against zint (composer reference:australia-post), covering all six Format Control Codes and every character of both tables at the front, middle and back of both field widths.
  • The fixture sweeps until all sixty-four parity codeword values have been drawn in all four parity positions — a generator polynomial right for three positions out of four is exactly what a fixture of chosen payloads misses.
  • The parity is also checked by its definition: the test builds GF(64) from the primitive polynomial itself and asserts every symbol's syndromes are zero at α¹ to α⁴, which is an opinion that does not pass through the class that made the symbol.
  • Rendered PNG measured back into bars, in DecoderRoundTripTest, with the family's standing no-free-decoder caveat and its expiry test.

Suite: 16103 tests, 269831 assertions. composer lint clean.

Closes the four-state family. An eight-digit sorting code, an optional
customer information field, and one option — the Format Control Code,
because the same sorting code drawn as Reply Paid and drawn as ordinary
mail are two different articles and nothing in the payload says which.

It is the only postal code here that corrects rather than detects: four
Reed-Solomon codewords over GF(64), reusing the field Aztec and MaxiCode
already brought. That is why the bars group in threes and why the
Standard Customer Barcode is thirty-seven bars rather than thirty-six —
a filler bar exists so the codeword count divides.

Both character tables are derived rather than transcribed: sixty-four
three-bar patterns and ten two-bar ones are one enumeration read at two
widths. The customer field is sized in bars, not characters, so a
half-filled field is refused rather than padded — filler bars in the
middle of a text field index as lower-case letters.

Verified bar for bar against zint over 527 symbols, swept until every
parity codeword value appears in every parity position, plus the parity
checked by its definition in a field the test builds for itself.
@s2x
s2x merged commit 28a74c0 into v2 Sep 3, 2026
5 checks passed
@s2x
s2x deleted the v2-australia-post branch September 3, 2026 20:37
s2x added a commit that referenced this pull request Sep 3, 2026
Australia Post, the postal code that repairs what it reads
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant