Skip to content

Commit

Permalink
Merge pull request #591 from dalferth/code39-extended-mode
Browse files Browse the repository at this point in the history
added code39 extended mode decode hint
  • Loading branch information
werthdavid authored Apr 29, 2024
2 parents 99a8e0c + 6a09746 commit cf4b897
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/core/DecodeHintType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ enum DecodeHintType {
*/
ASSUME_CODE_39_CHECK_DIGIT/*(Void.class)*/,

/**
* Enable extended mode for Code 39 codes. Doesn't matter what it maps to;
* use {@link Boolean#TRUE}.
*/
ENABLE_CODE_39_EXTENDED_MODE/*(Void.class)*/,

/**
* Assume the barcode is being processed as a GS1 barcode, and modify behavior as needed.
* For example this affects FNC1 handling for Code 128 (aka GS1-128). Doesn't matter what it maps to;
Expand Down
3 changes: 2 additions & 1 deletion src/core/oned/MultiFormatOneDReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default class MultiFormatOneDReader extends OneDReader {
super();
const possibleFormats = !hints ? null : <BarcodeFormat[]>hints.get(DecodeHintType.POSSIBLE_FORMATS);
const useCode39CheckDigit = hints && hints.get(DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT) !== undefined;
const useCode39ExtendedMode = hints && hints.get(DecodeHintType.ENABLE_CODE_39_EXTENDED_MODE) !== undefined;

if (possibleFormats) {
if (possibleFormats.includes(BarcodeFormat.EAN_13) ||
Expand All @@ -52,7 +53,7 @@ export default class MultiFormatOneDReader extends OneDReader {
this.readers.push(new MultiFormatUPCEANReader(hints));
}
if (possibleFormats.includes(BarcodeFormat.CODE_39)) {
this.readers.push(new Code39Reader(useCode39CheckDigit));
this.readers.push(new Code39Reader(useCode39CheckDigit, useCode39ExtendedMode));
}
if (possibleFormats.includes(BarcodeFormat.CODE_93)) {
this.readers.push(new Code93Reader());
Expand Down

0 comments on commit cf4b897

Please sign in to comment.