From 8e76cb3c8ddd30d96ff4048d2141b343f46195e9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Mar 2026 13:06:35 +0000 Subject: [PATCH] Replace hex encoding with ^NNN caret notation for Aztec barcode rendering Use bwip-js parse option with ^NNN decimal caret notation instead of the hexadecimal encoding option for binary data in Aztec codes. https://claude.ai/code/session_016McigfPtm5LUKCxWyEic55 --- website/src/lib/aztec.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/website/src/lib/aztec.ts b/website/src/lib/aztec.ts index 3e17d01..a4b00e8 100644 --- a/website/src/lib/aztec.ts +++ b/website/src/lib/aztec.ts @@ -5,16 +5,15 @@ export function renderAztec( data: Uint8Array, scale: number = 3, ): void { - // bwip-js expects hex string for binary data - const hex = Array.from(data) - .map((b) => b.toString(16).padStart(2, '0')) + // Convert binary data to ^NNN caret notation for bwip-js + const text = Array.from(data) + .map((b) => `^${b.toString().padStart(3, '0')}`) .join(''); - // The 'encoding' option is supported at runtime but not in the type defs bwipjs.toCanvas(canvas, { bcid: 'azteccode', - text: hex, - encoding: 'hexadecimal', + text, + parse: true, scale, eclevel: 23, } as bwipjs.RenderOptions);