Barcode

The barcode encoders on their own: a value in, bar geometry out, with no markup and no rendering. Fourteen linear symbologies, all written from scratch in C# — no JavaScript, no image request and no dependency.

Encode and Inspect

A BarcodeSymbol is geometry and nothing else: no colour, no size, no quiet zone drawn. The bars below are built in this page from symbol.Bars, which is all a renderer has to do. Each bar carries Start and Width in modules, plus Top and Bottom as fractions of the bar area — which is how the postal codes carry their data in the heights and the retail codes get the descenders their digits sit between.

The Value Is a Rule, Not a String

Each symbology has its own alphabet, its own length rule and its own check digit, and the encoder enforces all three rather than producing a symbol no reader will accept. Where a check digit is part of the standard it is always worked out and appended, so BarcodeSymbol.Value is not always what was passed in. Store that where the number has to match what a scanner will report.

What Each Symbology Accepts

DescribeInput returns a short sentence describing what a symbology accepts, for an error message or a form hint. It is what keeps a validation message and a placeholder in step with the encoder rather than being written out twice.

Two Symbologies Must Not Be Squashed

Most symbologies carry their data in the bar widths and leave every bar full height, so Top is 0 and Bottom is 1. POSTNET and the Royal Mail 4-state code carry it in the heights instead. Check IsHeightModulated before letting a layout shorten the bars: on those two it destroys the data rather than just making the symbol harder to aim at.

Encode Throws on a Bad Value

A character or a length the symbology cannot carry, or a value that ends in a check digit that does not match, raises a BarcodeFormatException whose message names the offending character or the expected length. It derives from ArgumentException, so an existing catch still works — but its Message is exactly that sentence with nothing appended, which is what makes it say the same thing on WebAssembly as on Server. Catch it in a Blazor component and render the message rather than letting it escape — an unhandled exception on Blazor Server takes the circuit down. BbBarcode already does this.

Verification

Every symbol matches zint bar for bar — position, width and height, in modules — and every symbology a reader library supports was decoded back to its original text by zxing-cpp.