docs(calibration.js): explain why one UTF-8 repair pass suffices in JS
TextEncoder always emits well-formed UTF-8, so truncation can strand at most a lead byte plus three continuations — one repair pass covers it. The C++ hub needs a loop because its input is raw bytes off the wire. Also drops a dead variable from the byte-boundary test. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
48d62c1f80
commit
7312dd0ca0
@@ -69,12 +69,7 @@ test('normaliseCal cuts a mid-rune byte boundary back to the last complete rune'
|
||||
});
|
||||
|
||||
test('normaliseCal leaves a unit that is exactly 16 bytes ending on a complete multi-byte rune untouched', () => {
|
||||
// 7 ASCII chars + 'Ω' (2 bytes) + 6 ASCII chars + 'µ' (2 bytes) - 1 = let's
|
||||
// build exactly 16 bytes ending on a complete 2-byte rune.
|
||||
// 7 × 'a' (7 bytes) + 'Ω' (2 bytes) + 5 × 'b' (5 bytes) + '°' (2 bytes) =
|
||||
// 7 + 2 + 5 + 2 = 16 bytes.
|
||||
const exact = 'aaaaaaаbbbbb°'; // avoid confusion: use simple construction below
|
||||
// Simple: 'abcdefgΩhijklµ' → 7 + 2 + 5 + 2 = 16 bytes
|
||||
// 'abcdefgΩhijklµ' → 7 ASCII + 'Ω' (2 bytes) + 5 ASCII + 'µ' (2 bytes) = 16 bytes
|
||||
const u = 'abcdefgΩhijklµ';
|
||||
assert.strictEqual(new TextEncoder().encode(u).length, 16);
|
||||
assert.strictEqual(C.normaliseCal({source: 'w', signal: 's', unit: u}).unit, u);
|
||||
|
||||
Reference in New Issue
Block a user