Minor changes to support EAN-13.

git-svn-id: https://zxing.googlecode.com/svn/trunk@101 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
dswitkin 2007-12-07 20:50:23 +00:00
parent 34c8f125ce
commit 776c3db869
2 changed files with 9 additions and 9 deletions

View file

@ -25,10 +25,10 @@ public final class UPCParsedResult extends ParsedReaderResult {
public UPCParsedResult(String rawText) {
super(ParsedReaderResultType.UPC);
if (rawText.length() != 12) {
if (rawText.length() != 12 && rawText.length() != 13) {
throw new IllegalArgumentException("Wrong number of digits for UPC");
}
for (int x = 0; x < 12; x++) {
for (int x = 0; x < rawText.length(); x++) {
char c = rawText.charAt(x);
if (c < '0' || c > '9') {
throw new IllegalArgumentException("Invalid character found in UPC");

View file

@ -236,12 +236,12 @@ final class UPCDecoder {
private int decodeOneSide(BitArray rowData, int rowOffset, boolean checkBothParities) {
int[] counters = new int[4];
byte firstDigitPattern = 0;
CharResult foundChar = new CharResult();
for (int x = 0; x < 6 && rowOffset < width; x++) {
recordPattern(rowData, rowOffset, counters, 4);
for (int y = 0; y < 4; y++) {
rowOffset += counters[y];
}
CharResult foundChar = new CharResult();
findDigit(counters, foundChar, checkBothParities);
if (foundChar.parity == UNKNOWN_PARITY) {
return -1;