Skip to content

Commit 36495ef

Browse files
committed
DataBar: fix inconsistency / plain spec violation (missing "(01)" prefix)
The GS1 DataBar ISO specification clearly states in Section 9 that our two BarcodeFormats DataBar and DataBarLimited always implicitly encode the AI "01" prefix. This has been implemented in the new DataBarLimited version but not in the old DataBar variant. Also to make the HRI of all DataBar variants (including the Expanded variant) consistent, all of them are now reported to contain GS1 data and hence be rendered as "(01)0123...." instead of "010123....".
1 parent efffdcf commit 36495ef

File tree

23 files changed

+25
-24
lines changed

23 files changed

+25
-24
lines changed

core/src/oned/ODDataBarLimitedReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Barcode DataBarLimitedReader::decodePattern(int rowNumber, PatternView& next, st
154154
continue;
155155

156156
return {ConstructText(left, right), rowNumber, next.pixelsInFront(), next.pixelsTillEnd(),
157-
BarcodeFormat::DataBarLimited, {'e', '0'}};
157+
BarcodeFormat::DataBarLimited, {'e', '0', 0, AIFlag::GS1}};
158158
}
159159

160160
// guarantee progress (see loop in ODReader.cpp)

core/src/oned/ODDataBarReader.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ static bool ChecksumIsValid(Pair leftPair, Pair rightPair)
140140
static std::string ConstructText(Pair leftPair, Pair rightPair)
141141
{
142142
auto txt = ToString(Value(leftPair, rightPair), 13);
143-
return txt + GTIN::ComputeCheckDigit(txt);
143+
// see ISO/IEC 24724:2011 Section 9
144+
return "01" + txt + GTIN::ComputeCheckDigit(txt);
144145
}
145146

146147
struct State : public RowReader::DecodingState
@@ -193,7 +194,7 @@ Barcode DataBarReader::decodePattern(int rowNumber, PatternView& next, std::uniq
193194
for (const auto& rightPair : prevState->rightPairs)
194195
if (ChecksumIsValid(leftPair, rightPair)) {
195196
// Symbology identifier ISO/IEC 24724:2011 Section 9 and GS1 General Specifications 5.1.3 Figure 5.1.3-2
196-
Barcode res{DecoderResult(Content(ByteArray(ConstructText(leftPair, rightPair)), {'e', '0'}))
197+
Barcode res{DecoderResult(Content(ByteArray(ConstructText(leftPair, rightPair)), {'e', '0', 0, AIFlag::GS1}))
197198
.setLineCount(EstimateLineCount(leftPair, rightPair)),
198199
{{}, EstimatePosition(leftPair, rightPair)},
199200
BarcodeFormat::DataBar};

test/samples/rss14-1/1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
04412345678909
1+
0104412345678909

test/samples/rss14-1/2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
00821935106427
1+
0100821935106427

test/samples/rss14-1/3.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
00075678164125
1+
0100075678164125

test/samples/rss14-1/4.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20012345678909
1+
0120012345678909

test/samples/rss14-1/5.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
00034567890125
1+
0100034567890125

test/samples/rss14-1/6.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
00012345678905
1+
0100012345678905
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20358468019312
1+
0120358468019312

test/samples/rss14-2/11.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
02001234567893
1+
0102001234567893

0 commit comments

Comments
 (0)