From bd06400a5b08b9e7b6a90deb6c86fdf3b015c803 Mon Sep 17 00:00:00 2001 From: gitlost Date: Mon, 13 Sep 2021 18:49:25 +0100 Subject: [PATCH] CODE93: add option_2 = 1 to display check chars in HRT --- ChangeLog | 1 + backend/code.c | 6 ++++++ backend/tests/test_code.c | 22 ++++++++++++---------- docs/manual.txt | 12 +++++++----- frontend_qt/CMakeLists.txt | 10 +++++----- frontend_qt/mainwindow.cpp | 24 ++++++++++++++++++++++++ frontend_qt/resources.qrc | 1 + 7 files changed, 56 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0af3d5a7..0334b33c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ Changes ------- - RMQR: add ECI support - CODE93: don't display check characters in HRT (as per standard Figure B1) + unless option_2 = 1 or vers=1 - GUI: separate out MAXICODE Structured Carrier Message fields Bugs diff --git a/backend/code.c b/backend/code.c index 4c272ab6..51976e00 100644 --- a/backend/code.c +++ b/backend/code.c @@ -517,6 +517,12 @@ INTERNAL int c93(struct zint_symbol *symbol, unsigned char source[], int length) (void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/); #endif + if (symbol->option_2 == 1) { + symbol->text[length] = set_copy[c]; + symbol->text[length + 1] = set_copy[k]; + symbol->text[length + 2] = '\0'; + } + return error_number; } diff --git a/backend/tests/test_code.c b/backend/tests/test_code.c index 21e70ccc..a6d8163f 100644 --- a/backend/tests/test_code.c +++ b/backend/tests/test_code.c @@ -132,16 +132,18 @@ static void test_hrt(int index, int debug) { /* 14*/ { BARCODE_LOGMARS, 1, "abc1234", -1, "ABC12340" }, // With check digit /* 15*/ { BARCODE_LOGMARS, 1, "12345/ABCDE", -1, "12345/ABCDET" }, // With check digit /* 16*/ { BARCODE_CODE93, -1, "ABC1234", -1, "ABC1234" }, // No longer shows 2 check chars added (same as BWIPP and TEC-IT) - /* 17*/ { BARCODE_CODE93, -1, "abc1234", -1, "abc1234" }, - /* 18*/ { BARCODE_CODE93, -1, "A\001a\000b\177d\037e", 9, "A a b d e" }, // NUL, ctrls and DEL replaced with spaces - /* 19*/ { BARCODE_PZN, -1, "12345", -1, "PZN -00123458" }, // Pads with zeroes if length < 7 - /* 20*/ { BARCODE_PZN, -1, "123456", -1, "PZN -01234562" }, - /* 21*/ { BARCODE_PZN, -1, "1234567", -1, "PZN -12345678" }, - /* 22*/ { BARCODE_VIN, -1, "1FTCR10UXTPA78180", -1, "1FTCR10UXTPA78180" }, - /* 23*/ { BARCODE_VIN, 1, "2FTPX28L0XCA15511", -1, "2FTPX28L0XCA15511" }, // Include Import char - no change - /* 24*/ { BARCODE_HIBC_39, -1, "ABC1234", -1, "*+ABC1234+*" }, - /* 25*/ { BARCODE_HIBC_39, -1, "abc1234", -1, "*+ABC1234+*" }, // Converts to upper - /* 26*/ { BARCODE_HIBC_39, -1, "123456789", -1, "*+1234567890*" }, + /* 17*/ { BARCODE_CODE93, 1, "ABC1234", -1, "ABC1234S5" }, // Unless requested + /* 18*/ { BARCODE_CODE93, -1, "abc1234", -1, "abc1234" }, + /* 19*/ { BARCODE_CODE93, 1, "abc1234", -1, "abc1234ZG" }, + /* 20*/ { BARCODE_CODE93, -1, "A\001a\000b\177d\037e", 9, "A a b d e" }, // NUL, ctrls and DEL replaced with spaces + /* 21*/ { BARCODE_PZN, -1, "12345", -1, "PZN -00123458" }, // Pads with zeroes if length < 7 + /* 22*/ { BARCODE_PZN, -1, "123456", -1, "PZN -01234562" }, + /* 23*/ { BARCODE_PZN, -1, "1234567", -1, "PZN -12345678" }, + /* 24*/ { BARCODE_VIN, -1, "1FTCR10UXTPA78180", -1, "1FTCR10UXTPA78180" }, + /* 25*/ { BARCODE_VIN, 1, "2FTPX28L0XCA15511", -1, "2FTPX28L0XCA15511" }, // Include Import char - no change + /* 26*/ { BARCODE_HIBC_39, -1, "ABC1234", -1, "*+ABC1234+*" }, + /* 27*/ { BARCODE_HIBC_39, -1, "abc1234", -1, "*+ABC1234+*" }, // Converts to upper + /* 28*/ { BARCODE_HIBC_39, -1, "123456789", -1, "*+1234567890*" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/docs/manual.txt b/docs/manual.txt index 6cabb1fb..d9587b85 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -1561,8 +1561,8 @@ the Human Readable Text, set option_2 = 2 or --vers=2. Used for baggage handling in the air-transport industry by the International Air Transport Agency, this self-checking code will encode any length numeric input (digits 0-9). No check digit is added by default. To add a check digit, -set option_2 = 1 or --vers=1. To add a check digit but not show it in the human -readable text, set option_2 = 2 or --vers=2. +set option_2 = 1 or --vers=1. To add a check digit but not show it in the Human +Readable Text, set option_2 = 2 or --vers=2. 6.1.2.3 Industrial Code 2 of 5 ------------------------------ @@ -1576,8 +1576,8 @@ option_2 = 2 or --vers=2. This self-checking symbology encodes pairs of numbers, and so can only encode an even number of digits (0-9). If an odd number of digits is entered a leading zero is added by Zint. No check digit is added by default. To add a check digit, -set option_2 = 1 or --vers=1. To add a check digit but not show it in the human -readable text, set option_2 = 2 or --vers=2. +set option_2 = 1 or --vers=1. To add a check digit but not show it in the Human +Readable Text, set option_2 = 2 or --vers=2. 6.1.2.5 Code 2 of 5 Data Logic ------------------------------ @@ -1769,7 +1769,9 @@ setting option_2 = 1 or using --vers=1. 6.1.8.3 Code 93 --------------- A variation of Extended Code 39, Code 93 also supports full ASCII text. Two -check digits are added by Zint. +check characters are added by Zint. By default these check characters are not +shown in the Human Readable Text, but may be shown by setting option_2 = 1 or +using vers=1. 6.1.8.4 PZN (Pharmazentralnummer) --------------------------------- diff --git a/frontend_qt/CMakeLists.txt b/frontend_qt/CMakeLists.txt index 0b11c83d..8cf9571e 100644 --- a/frontend_qt/CMakeLists.txt +++ b/frontend_qt/CMakeLists.txt @@ -16,11 +16,11 @@ else() qt5_wrap_ui(zint-qt_SRCS mainWindow.ui extData.ui extSequence.ui extExport.ui) endif() -# grpAztec.ui grpC39.ui grpCodeOne.ui grpGrid.ui grpMQR.ui grpUltra.ui -# grpC11.ui grpC49.ui grpDAFT.ui grpHX.ui grpMSICheck.ui grpUPCA.ui -# grpC128.ui grpChannel.ui grpDBExtend.ui grpLOGMARS.ui grpPDF417.ui grpUPCEAN.ui -# grpC16k.ui grpCodabar.ui grpDM.ui grpMaxicode.ui grpQR.ui grpVIN.ui -# grpC25.ui grpCodablockF.ui grpDotCode.ui grpMicroPDF.ui grpRMQR.ui +# grpAztec.ui grpC39.ui grpCodablockF.ui grpDotCode.ui grpMicroPDF.ui grpRMQR.ui +# grpC11.ui grpC49.ui grpCodeOne.ui grpGrid.ui grpMQR.ui grpUltra.ui +# grpC128.ui grpC93.ui grpDAFT.ui grpHX.ui grpMSICheck.ui grpUPCA.ui +# grpC16k.ui grpChannel.ui grpDBExtend.ui grpLOGMARS.ui grpPDF417.ui grpUPCEAN.ui +# grpC25.ui grpCodabar.ui grpDM.ui grpMaxicode.ui grpQR.ui grpVIN.ui add_executable(${PROJECT_NAME} ${zint-qt_SRCS} resources.qrc) diff --git a/frontend_qt/mainwindow.cpp b/frontend_qt/mainwindow.cpp index f046fe35..67707eb7 100644 --- a/frontend_qt/mainwindow.cpp +++ b/frontend_qt/mainwindow.cpp @@ -933,6 +933,15 @@ void MainWindow::change_options() connect(m_optionWidget->findChild("cmbC49RowSepHeight"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview())); connect(m_optionWidget->findChild("radC49GS1"), SIGNAL(toggled( bool )), SLOT(update_preview())); + } else if (symbology == BARCODE_CODE93) { + QFile file(":/grpC93.ui"); + if (file.open(QIODevice::ReadOnly)) { + m_optionWidget = uiload.load(&file); + file.close(); + tabMain->insertTab(1, m_optionWidget, tr("Cod&e 93")); + connect(m_optionWidget->findChild("chkC93ShowChecks"), SIGNAL(clicked( bool )), SLOT(update_preview())); + } + } else if (symbology == BARCODE_DBAR_EXPSTK) { QFile file(":/grpDBExtend.ui"); if (!file.open(QIODevice::ReadOnly)) @@ -1596,6 +1605,13 @@ void MainWindow::update_preview() } break; + case BARCODE_CODE93: + m_bc.bc.setSymbol(BARCODE_CODE93); + if (get_checkbox_val("chkC93ShowChecks")) { + m_bc.bc.setOption2(1); + } + break; + case BARCODE_HANXIN: m_bc.bc.setSymbol(BARCODE_HANXIN); item_val = m_optionWidget->findChild("cmbHXSize")->currentIndex(); @@ -2154,6 +2170,10 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology) { settings.setValue("studio/bc/code49/encoding_mode", get_button_group_index(QStringList() << "radC49Stand" << "radC49GS1")); break; + case BARCODE_CODE93: + settings.setValue("studio/bc/code93/chk_show_checks", get_checkbox_val("chkC93ShowChecks")); + break; + case BARCODE_DBAR_EXPSTK: case BARCODE_DBAR_EXPSTK_CC: settings.setValue("studio/bc/dbar_expstk/cols", get_combobox_index("cmbCols")); @@ -2410,6 +2430,10 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology) { set_radiobutton_from_setting(settings, "studio/bc/code49/encoding_mode", QStringList() << "radC49Stand" << "radC49GS1"); break; + case BARCODE_CODE93: + set_checkbox_from_setting(settings, "studio/bc/code93/chk_show_checks", "chkC93ShowChecks"); + break; + case BARCODE_DBAR_EXPSTK: set_combobox_from_setting(settings, "studio/bc/dbar_expstk/cols", "cmbCols"); break; diff --git a/frontend_qt/resources.qrc b/frontend_qt/resources.qrc index ee3c5f70..1e8527f3 100644 --- a/frontend_qt/resources.qrc +++ b/frontend_qt/resources.qrc @@ -7,6 +7,7 @@ grpC25.ui grpC39.ui grpC49.ui + grpC93.ui grpChannel.ui grpCodabar.ui grpCodablockF.ui