mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
asterisk isn't a valid character and should not be encoded as content with Code 39. (#872)
* asterisk isn't a valid character which can be encoded with Code 39. the following sample content results in an unreadable barcode: *123456789 because the asterisk is the start-stop character (special meaning, not valid in content) the really encoded value is **123456789*. The barcode reader stops after reading the second asterisk and throw the content away. * remove wrong private modifier for ALPHABET_STRING * cleanup comments
This commit is contained in:
parent
6ca929ee26
commit
1d66d793ed
|
@ -36,9 +36,7 @@ import java.util.Map;
|
|||
*/
|
||||
public final class Code39Reader extends OneDReader {
|
||||
|
||||
static final String ALPHABET_STRING = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%";
|
||||
// Note this lacks '*' compared to ALPHABET_STRING
|
||||
private static final String CHECK_DIGIT_STRING = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%";
|
||||
static final String ALPHABET_STRING = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%";
|
||||
|
||||
/**
|
||||
* These represent the encodings of characters, as patterns of wide and narrow bars.
|
||||
|
@ -49,11 +47,11 @@ public final class Code39Reader extends OneDReader {
|
|||
0x034, 0x121, 0x061, 0x160, 0x031, 0x130, 0x070, 0x025, 0x124, 0x064, // 0-9
|
||||
0x109, 0x049, 0x148, 0x019, 0x118, 0x058, 0x00D, 0x10C, 0x04C, 0x01C, // A-J
|
||||
0x103, 0x043, 0x142, 0x013, 0x112, 0x052, 0x007, 0x106, 0x046, 0x016, // K-T
|
||||
0x181, 0x0C1, 0x1C0, 0x091, 0x190, 0x0D0, 0x085, 0x184, 0x0C4, 0x094, // U-*
|
||||
0x0A8, 0x0A2, 0x08A, 0x02A // $-%
|
||||
0x181, 0x0C1, 0x1C0, 0x091, 0x190, 0x0D0, 0x085, 0x184, 0x0C4, 0x0A8, // U-$
|
||||
0x0A2, 0x08A, 0x02A // /-%
|
||||
};
|
||||
|
||||
static final int ASTERISK_ENCODING = CHARACTER_ENCODINGS[39];
|
||||
static final int ASTERISK_ENCODING = 0x094;
|
||||
|
||||
private final boolean usingCheckDigit;
|
||||
private final boolean extendedMode;
|
||||
|
@ -145,9 +143,9 @@ public final class Code39Reader extends OneDReader {
|
|||
int max = result.length() - 1;
|
||||
int total = 0;
|
||||
for (int i = 0; i < max; i++) {
|
||||
total += CHECK_DIGIT_STRING.indexOf(decodeRowResult.charAt(i));
|
||||
total += ALPHABET_STRING.indexOf(decodeRowResult.charAt(i));
|
||||
}
|
||||
if (result.charAt(max) != CHECK_DIGIT_STRING.charAt(total % 43)) {
|
||||
if (result.charAt(max) != ALPHABET_STRING.charAt(total % 43)) {
|
||||
throw ChecksumException.getChecksumInstance();
|
||||
}
|
||||
result.setLength(max);
|
||||
|
@ -262,6 +260,9 @@ public final class Code39Reader extends OneDReader {
|
|||
return ALPHABET_STRING.charAt(i);
|
||||
}
|
||||
}
|
||||
if (pattern == ASTERISK_ENCODING) {
|
||||
return '*';
|
||||
}
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue