{"abstract":"Payloads with accented letters or the euro sign overflow the chosen version and are truncated by the encoder.","category":"Barcode symbology encoding","checks":8,"contract":"Compute the length in bits of one QR segment: 4-bit mode indicator, a character count indicator whose width depends on mode and version band (1-9, 10-26, 27-40): numeric 10/12/14, alphanumeric 9/11/13, byte 8/16/16, and the data bits: numeric 10 bits per 3 digits plus 4 or 7 for a remainder of 1 or 2, alphanumeric 11 bits per pair plus 6 for a single, byte 8 bits per UTF-8 byte. Alphanumeric allows 0-9 A-Z space $ % * + - . / :. A count that does not fit the indicator is too-long. Errors: version, charset, mode, too-long.","contract_signature":"mode, data, version","evaluation_group":"w2-barcode-symbology-encoding-qr-segment-bits","failed_approach":"Encoding as Latin-1 with replacement still yields one byte per character.","family":"w2-barcode-symbology-encoding-qr-segment-bits-byte-count","id":"FA-79651","implementations":{"attempt":{"sha256":"c3a36e978961193cf57c2460520f605176ef39d4f4c33f4ec7e2aa88f832de54","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(mode, data, version):\n    if not 1 <= version <= 40:\n        return {'error': 'version'}\n    band = 0 if version <= 9 else (1 if version <= 26 else 2)\n    ALNUM = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'\n    if mode == 'numeric':\n        if not all(c in '0123456789' for c in data):\n            return {'error': 'charset'}\n        count = len(data)\n        bits = 10 * (count // 3) + [0, 4, 7][count % 3]\n        cci = [10, 12, 14][band]\n    elif mode == 'alnum':\n        if not all(c in ALNUM for c in data):\n            return {'error': 'charset'}\n        count = len(data)\n        bits = 11 * (count // 2) + 6 * (count % 2)\n        cci = [9, 11, 13][band]\n    elif mode == 'byte':\n        count = len(data.encode('latin-1', 'replace'))\n        bits = 8 * count\n        cci = [8, 16, 16][band]\n    else:\n        return {'error': 'mode'}\n    if count >= 1 << cci:\n        return {'error': 'too-long'}\n    return 4 + cci + bits\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[('byte', '1€11€é', 40), 108], [('byte', '€éa1a1 ', 9), 92], [('alnum', '-/$é+/%é+', 0), {'error': 'version'}], [('alnum', '-', 1), 19], [('alnum', '%', 1), 19], [('alnum', 'ééA- q', 9), {'error': 'charset'}], [('byte', '', 1), 12], [('byte', '€1é ', 27), 76]], [[('byte', 'ébba', 27), 60], [('byte', 'é1 ', 27), 52], [('numeric', '053142', 0), {'error': 'version'}], [('numeric', '089405', 10), 36], [('kanji', 'b1ab11', 5), {'error': 'mode'}], [('alnum', 'q+$ ', 40), {'error': 'charset'}], [('alnum', '++$:é1*.+', 10), {'error': 'charset'}], [('byte', 'ébé', 1), 52]], [[('byte', '1abé', 1), 52], [('byte', 'é  ', 5), 44], [('numeric', '00575', 9), 31], [('numeric', '37219', 5), 31], [('numeric', '', 40), 18], [('numeric', '716925614701', 5), 54], [('kanji', 'é b€b', 10), {'error': 'mode'}], [('byte', '€a€', 10), 76]], [[('byte', 'é€ééa ba', 15), 124], [('byte', 'b€a', 1), 52], [('byte', '€', 41), {'error': 'version'}], [('numeric', '', 0), {'error': 'version'}], [('numeric', '2', 1), 18], [('alnum', '%1.qZ-', 5), {'error': 'charset'}], [('alnum', 'A:*éZA', 40), {'error': 'charset'}], [('byte', 'éb aa€a', 10), 100]], [[('byte', ' a bbé', 10), 76], [('byte', '111bé1', 5), 68], [('kanji', 'éb', 1), {'error': 'mode'}], [('alnum', '.', 5), 19], [('numeric', '4813206244', 15), 50], [('numeric', '19928871', 5), 41], [('numeric', '', 1), 14], [('byte', 'a€', 26), 52]]]\nlabels = [\"regression: byte mode length unit\", \"repair trap\", \"combined fault\", \"control\", \"control\", \"boundary\", \"boundary\", \"control\"]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (labels[i % len(labels)], i), solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"196e6602fcf7ec1a21c4080008c67c1b948764b3b6aac67ae842c8a74f6c4ac1","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(mode, data, version):\n    if not 1 <= version <= 40:\n        return {'error': 'version'}\n    band = 0 if version <= 9 else (1 if version <= 26 else 2)\n    ALNUM = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'\n    if mode == 'numeric':\n        if not all(c in '0123456789' for c in data):\n            return {'error': 'charset'}\n        count = len(data)\n        bits = 10 * (count // 3) + [0, 4, 7][count % 3]\n        cci = [10, 12, 14][band]\n    elif mode == 'alnum':\n        if not all(c in ALNUM for c in data):\n            return {'error': 'charset'}\n        count = len(data)\n        bits = 11 * (count // 2) + 6 * (count % 2)\n        cci = [9, 11, 13][band]\n    elif mode == 'byte':\n        count = len(data)\n        bits = 8 * count\n        cci = [8, 16, 16][band]\n    else:\n        return {'error': 'mode'}\n    if count >= 1 << cci:\n        return {'error': 'too-long'}\n    return 4 + cci + bits\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[('byte', '1€11€é', 40), 108], [('byte', '€éa1a1 ', 9), 92], [('alnum', '-/$é+/%é+', 0), {'error': 'version'}], [('alnum', '-', 1), 19], [('alnum', '%', 1), 19], [('alnum', 'ééA- q', 9), {'error': 'charset'}], [('byte', '', 1), 12], [('byte', '€1é ', 27), 76]], [[('byte', 'ébba', 27), 60], [('byte', 'é1 ', 27), 52], [('numeric', '053142', 0), {'error': 'version'}], [('numeric', '089405', 10), 36], [('kanji', 'b1ab11', 5), {'error': 'mode'}], [('alnum', 'q+$ ', 40), {'error': 'charset'}], [('alnum', '++$:é1*.+', 10), {'error': 'charset'}], [('byte', 'ébé', 1), 52]], [[('byte', '1abé', 1), 52], [('byte', 'é  ', 5), 44], [('numeric', '00575', 9), 31], [('numeric', '37219', 5), 31], [('numeric', '', 40), 18], [('numeric', '716925614701', 5), 54], [('kanji', 'é b€b', 10), {'error': 'mode'}], [('byte', '€a€', 10), 76]], [[('byte', 'é€ééa ba', 15), 124], [('byte', 'b€a', 1), 52], [('byte', '€', 41), {'error': 'version'}], [('numeric', '', 0), {'error': 'version'}], [('numeric', '2', 1), 18], [('alnum', '%1.qZ-', 5), {'error': 'charset'}], [('alnum', 'A:*éZA', 40), {'error': 'charset'}], [('byte', 'éb aa€a', 10), 100]], [[('byte', ' a bbé', 10), 76], [('byte', '111bé1', 5), 68], [('kanji', 'éb', 1), {'error': 'mode'}], [('alnum', '.', 5), 19], [('numeric', '4813206244', 15), 50], [('numeric', '19928871', 5), 41], [('numeric', '', 1), 14], [('byte', 'a€', 26), 52]]]\nlabels = [\"regression: byte mode length unit\", \"repair trap\", \"combined fault\", \"control\", \"control\", \"boundary\", \"boundary\", \"control\"]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (labels[i % len(labels)], i), solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"A deterministic bounded teaching model with a stipulated contract; it makes no claim of conformance to any published specification. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-barcode-symbology-encoding-qr-segment-bits-byte-count","generated_at":"2026-09-29T14:49:46.387038+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Retail, logistics, pharmacy and document workflows depend on encoders that produce exactly the module pattern, code-set switches, separators and quiet zones scanners expect; one misplaced module or separator makes a label unreadable or, worse, scan as different data.","root_cause":"The byte segment length is the number of code points.","sha256":"3f6a0618a0fc904d6c3a734289565b6e61a44db13298d1f392bdc1a5d44d3d4b","title":"Byte mode counts characters instead of UTF-8 bytes · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":38.167,"exit_code":1,"observations":[{"actual":68,"check":"regression: byte mode length unit 0","expected":108,"passed":false},{"actual":68,"check":"repair trap 1","expected":92,"passed":false},{"actual":{"error":"version"},"check":"combined fault 2","expected":{"error":"version"},"passed":true},{"actual":19,"check":"control 3","expected":19,"passed":true},{"actual":19,"check":"control 4","expected":19,"passed":true},{"actual":{"error":"charset"},"check":"boundary 5","expected":{"error":"charset"},"passed":true},{"actual":12,"check":"boundary 6","expected":12,"passed":true},{"actual":52,"check":"control 7","expected":76,"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: byte mode length unit 0\", \"actual\": 68, \"expected\": 108, \"passed\": false}, {\"check\": \"repair trap 1\", \"actual\": 68, \"expected\": 92, \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": {\"error\": \"version\"}, \"expected\": {\"error\": \"version\"}, \"passed\": true}, {\"check\": \"control 3\", \"actual\": 19, \"expected\": 19, \"passed\": true}, {\"check\": \"control 4\", \"actual\": 19, \"expected\": 19, \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": {\"error\": \"charset\"}, \"expected\": {\"error\": \"charset\"}, \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": 12, \"expected\": 12, \"passed\": true}, {\"check\": \"control 7\", \"actual\": 52, \"expected\": 76, \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.187,"exit_code":1,"observations":[{"actual":68,"check":"regression: byte mode length unit 0","expected":108,"passed":false},{"actual":68,"check":"repair trap 1","expected":92,"passed":false},{"actual":{"error":"version"},"check":"combined fault 2","expected":{"error":"version"},"passed":true},{"actual":19,"check":"control 3","expected":19,"passed":true},{"actual":19,"check":"control 4","expected":19,"passed":true},{"actual":{"error":"charset"},"check":"boundary 5","expected":{"error":"charset"},"passed":true},{"actual":12,"check":"boundary 6","expected":12,"passed":true},{"actual":52,"check":"control 7","expected":76,"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: byte mode length unit 0\", \"actual\": 68, \"expected\": 108, \"passed\": false}, {\"check\": \"repair trap 1\", \"actual\": 68, \"expected\": 92, \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": {\"error\": \"version\"}, \"expected\": {\"error\": \"version\"}, \"passed\": true}, {\"check\": \"control 3\", \"actual\": 19, \"expected\": 19, \"passed\": true}, {\"check\": \"control 4\", \"actual\": 19, \"expected\": 19, \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": {\"error\": \"charset\"}, \"expected\": {\"error\": \"charset\"}, \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": 12, \"expected\": 12, \"passed\": true}, {\"check\": \"control 7\", \"actual\": 52, \"expected\": 76, \"passed\": false}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}