diff --git a/rust/src/lib.rs b/rust/src/lib.rs index eef02d1..147b542 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -567,10 +567,10 @@ impl QrCode { // Interleave (not concatenate) the bytes from every block into a single sequence let mut result = Vec::::with_capacity(rawcodewords); for i in 0 .. shortblocklen + 1 { - for j in 0 .. numblocks { + for (j, block) in blocks.iter().enumerate() { // Skip the padding byte in short blocks if i != shortblocklen - blockecclen || j >= numshortblocks { - result.push(blocks[j][i]); + result.push(block[i]); } } } diff --git a/typescript-javascript/qrcodegen.ts b/typescript-javascript/qrcodegen.ts index a7f0ab4..00e7827 100644 --- a/typescript-javascript/qrcodegen.ts +++ b/typescript-javascript/qrcodegen.ts @@ -435,11 +435,11 @@ namespace qrcodegen { // Interleave (not concatenate) the bytes from every block into a single sequence let result: Array = []; for (let i = 0; i < blocks[0].length; i++) { - for (let j = 0; j < blocks.length; j++) { + blocks.forEach((block, j) => { // Skip the padding byte in short blocks if (i != shortBlockLen - blockEccLen || j >= numShortBlocks) - result.push(blocks[j][i]); - } + result.push(block[i]); + }); } if (result.length != rawCodewords) throw "Assertion error";