From 8033f9cec037639a84baffcc1c7b33dbcb5a8513 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Fri, 10 Feb 2017 03:17:18 +0000 Subject: [PATCH] Fixed a constant value in QrSegmentAdvanced, which affects how the optimal segment switching is selected. --- java/io/nayuki/qrcodegen/QrSegmentAdvanced.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/java/io/nayuki/qrcodegen/QrSegmentAdvanced.java b/java/io/nayuki/qrcodegen/QrSegmentAdvanced.java index ef813bd..5caf956 100644 --- a/java/io/nayuki/qrcodegen/QrSegmentAdvanced.java +++ b/java/io/nayuki/qrcodegen/QrSegmentAdvanced.java @@ -109,7 +109,7 @@ public final class QrSegmentAdvanced { char c = (char)data[i]; result[0][j] = result[0][i] + 48; // 8 bits per byte if (isAlphanumeric(c)) - result[1][j] = result[1][i] + 39; // 6.5 bits per alphanumeric char + result[1][j] = result[1][i] + 33; // 5.5 bits per alphanumeric char if (isNumeric(c)) result[2][j] = result[2][i] + 20; // 3.33 bits per alphanumeric char @@ -148,7 +148,7 @@ public final class QrSegmentAdvanced { if (curMode == NUMERIC) { if (isNumeric(c)) curMode = NUMERIC; - else if (isAlphanumeric(c) && (bitCosts[1][i] + 39 + 5) / 6 * 6 + numberCost == bitCosts[2][i + 1]) + else if (isAlphanumeric(c) && (bitCosts[1][i] + 33 + 5) / 6 * 6 + numberCost == bitCosts[2][i + 1]) curMode = ALPHANUMERIC; else curMode = BYTE; @@ -162,7 +162,7 @@ public final class QrSegmentAdvanced { } else if (curMode == BYTE) { if (isNumeric(c) && (bitCosts[2][i] + 20 + 5) / 6 * 6 + bytesCost == bitCosts[0][i + 1]) curMode = NUMERIC; - else if (isAlphanumeric(c) && (bitCosts[1][i] + 39 + 5) / 6 * 6 + bytesCost == bitCosts[0][i + 1]) + else if (isAlphanumeric(c) && (bitCosts[1][i] + 33 + 5) / 6 * 6 + bytesCost == bitCosts[0][i + 1]) curMode = ALPHANUMERIC; else curMode = BYTE;