feat(barcodes): GS1-mode QR (#152) - #159
Merged
Merged
Conversation
Add a Gs1 option to QrCode with two modes, reusing the existing QR engine and the merged GS1 element-string / Digital Link helpers: - QrGs1Mode.ElementString encodes GS1 Application Identifier data with the FNC1-in-first-position mode indicator (ISO/IEC 18004 section 7.4.8.2), field separators carried as raw 0x1D bytes in byte mode. - QrGs1Mode.DigitalLink encodes the content as a canonical id.gs1.org GS1 Digital Link URI. The FNC1 indicator is counted toward version and capacity selection like the ECI header; the non-GS1 path is unchanged. Human-readable alt text shows the parenthesized-AI form for element strings or the URI for Digital Link. Decode round-trips verified against zxing-cpp: the element-string symbol reports content_type GS1, the Digital Link symbol its URI. Also fix a latent BarcodeRendererTests helper that did not mirror PdfLiteralString paren escaping.
…ntent fix Per adversarial review of #152: the FNC1 field separator (0x1D) and byte-mode GS1 payloads had no value-level coverage. Add a separator round-trip oracle (a multi-variable-AI payload with a real 0x1D separator, decode-verified as content_type GS1 with correctly reconstructed AI boundaries), a %-in-value oracle, always-on byte-mode-separator and multi-segment FNC1-exactly-once bit checks, and a capacity double-count guard. Also fix the exception contract: empty content with Gs1 set now throws FormatException (the documented contract) instead of a leaked ArgumentException from the GS1 parser.
This was referenced Jul 8, 2026
This was referenced Aug 19, 2026
This was referenced Sep 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Third symbology PR in the v1.10 barcode expansion (on
main, groundwork already merged).Adds a
Gs1option to the existingQrCode, reusing the QR engine and the mergedGs1ElementString/Gs1DigitalLinkhelpers — the highest effort-to-value item on the barcode roadmap.Modes (
QrGs1Mode)ElementString— encodes GS1 Application Identifier data with the FNC1-in-first-position mode indicator (0b0101, ISO/IEC 18004 §7.4.8.2). Field separators are carried as raw0x1Dbytes in byte mode; alphanumeric mode is deliberately disabled for GS1 content to avoid the mode-dependent%/%%escaping ambiguity (documented in code, both forms are spec-sanctioned). The 4 FNC1 bits are counted toward version/capacity selection like the ECI header.DigitalLink— encodes the content as a canonicalhttps://id.gs1.org/...Digital Link URI (an ordinary text QR).None(default) — the existing QR path is byte-for-byte unchanged.GS1 mode requires text content; combining it with the byte-array constructor throws. Alt text surfaces the parenthesized-AI HRI (element string) or the URI (Digital Link).
New public surface (
PublicAPI.Unshipped):QrGs1Mode(+ members) andQrCode.Gs1.Testing
New unit tests (FNC1 indicator + capacity accounting, both modes,
Noneregression guard), alt-text tests, and decode-oracle round-trips:QRCode,content_type == GS1, text(01)09501101020917(17)261231(10)ABC123.https://id.gs1.org/01/09501101020917/17/261231/10/ABC123.Also fixes a latent
BarcodeRendererTestshelper that didn't mirrorPdfLiteralString's parenthesis escaping (so parenthesized alt text could never match).Verified locally:
dotnet build -c Release(0 warnings), 671 tests pass (oracle ran for real — pdftoppm + zxing-cpp),dotnet format --verify-no-changesclean, clean-room check pass.