diff --git a/core/src/main/java/com/google/zxing/oned/Code39Reader.java b/core/src/main/java/com/google/zxing/oned/Code39Reader.java index 76eee5717..6a9a7e10c 100644 --- a/core/src/main/java/com/google/zxing/oned/Code39Reader.java +++ b/core/src/main/java/com/google/zxing/oned/Code39Reader.java @@ -37,7 +37,8 @@ import java.util.Map; public final class Code39Reader extends OneDReader { static final String ALPHABET_STRING = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%"; - private static final char[] ALPHABET = ALPHABET_STRING.toCharArray(); + // Note this lacks '*' compared to ALPHABET_STRING + private static final String CHECK_DIGIT_STRING = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"; /** * These represent the encodings of characters, as patterns of wide and narrow bars. @@ -52,7 +53,7 @@ public final class Code39Reader extends OneDReader { 0x0A8, 0x0A2, 0x08A, 0x02A // $-% }; - private static final int ASTERISK_ENCODING = CHARACTER_ENCODINGS[39]; + static final int ASTERISK_ENCODING = CHARACTER_ENCODINGS[39]; private final boolean usingCheckDigit; private final boolean extendedMode; @@ -144,9 +145,9 @@ public final class Code39Reader extends OneDReader { int max = result.length() - 1; int total = 0; for (int i = 0; i < max; i++) { - total += ALPHABET_STRING.indexOf(decodeRowResult.charAt(i)); + total += CHECK_DIGIT_STRING.indexOf(decodeRowResult.charAt(i)); } - if (result.charAt(max) != ALPHABET[total % 43]) { + if (result.charAt(max) != CHECK_DIGIT_STRING.charAt(total % 43)) { throw ChecksumException.getChecksumInstance(); } result.setLength(max); @@ -258,7 +259,7 @@ public final class Code39Reader extends OneDReader { private static char patternToChar(int pattern) throws NotFoundException { for (int i = 0; i < CHARACTER_ENCODINGS.length; i++) { if (CHARACTER_ENCODINGS[i] == pattern) { - return ALPHABET[i]; + return ALPHABET_STRING.charAt(i); } } throw NotFoundException.getNotFoundInstance(); diff --git a/core/src/main/java/com/google/zxing/oned/Code39Writer.java b/core/src/main/java/com/google/zxing/oned/Code39Writer.java index 8a498a0ab..0c1ad1cee 100644 --- a/core/src/main/java/com/google/zxing/oned/Code39Writer.java +++ b/core/src/main/java/com/google/zxing/oned/Code39Writer.java @@ -63,7 +63,7 @@ public final class Code39Writer extends OneDimensionalCodeWriter { } } boolean[] result = new boolean[codeWidth]; - toIntArray(Code39Reader.CHARACTER_ENCODINGS[39], widths); + toIntArray(Code39Reader.ASTERISK_ENCODING, widths); int pos = appendPattern(result, 0, widths, true); int[] narrowWhite = {1}; pos += appendPattern(result, pos, narrowWhite, false); @@ -74,7 +74,7 @@ public final class Code39Writer extends OneDimensionalCodeWriter { pos += appendPattern(result, pos, widths, true); pos += appendPattern(result, pos, narrowWhite, false); } - toIntArray(Code39Reader.CHARACTER_ENCODINGS[39], widths); + toIntArray(Code39Reader.ASTERISK_ENCODING, widths); appendPattern(result, pos, widths, true); return result; }