mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Fix bug that would cut out part of result string if final checksum value happened to be the code for a non-printable character
git-svn-id: https://zxing.googlecode.com/svn/trunk@584 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
e57cf71874
commit
b29b4d2070
|
@ -264,9 +264,12 @@ public final class Code128Reader extends AbstractOneDReader {
|
|||
int code = 0;
|
||||
int checksumTotal = startCode;
|
||||
int multiplier = 0;
|
||||
boolean lastCharacterWasPrintable = true;
|
||||
|
||||
while (!done) {
|
||||
|
||||
lastCharacterWasPrintable = true;
|
||||
|
||||
boolean unshift = isNextShifted;
|
||||
isNextShifted = false;
|
||||
|
||||
|
@ -298,6 +301,7 @@ public final class Code128Reader extends AbstractOneDReader {
|
|||
} else if (code < 96) {
|
||||
result.append((char) (code - 64));
|
||||
} else {
|
||||
lastCharacterWasPrintable = false;
|
||||
switch (code) {
|
||||
case CODE_FNC_1:
|
||||
case CODE_FNC_2:
|
||||
|
@ -325,6 +329,7 @@ public final class Code128Reader extends AbstractOneDReader {
|
|||
if (code < 96) {
|
||||
result.append((char) (' ' + code));
|
||||
} else {
|
||||
lastCharacterWasPrintable = false;
|
||||
switch (code) {
|
||||
case CODE_FNC_1:
|
||||
case CODE_FNC_2:
|
||||
|
@ -355,6 +360,7 @@ public final class Code128Reader extends AbstractOneDReader {
|
|||
}
|
||||
result.append(code);
|
||||
} else {
|
||||
lastCharacterWasPrintable = false;
|
||||
switch (code) {
|
||||
case CODE_FNC_1:
|
||||
// do nothing?
|
||||
|
@ -397,7 +403,7 @@ public final class Code128Reader extends AbstractOneDReader {
|
|||
|
||||
// Need to pull out the check digits from string
|
||||
int resultLength = result.length();
|
||||
if (resultLength > 0) {
|
||||
if (resultLength > 0 && lastCharacterWasPrintable) {
|
||||
if (codeSet == CODE_CODE_C) {
|
||||
result.delete(resultLength - 2, resultLength);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue