GS1PARENS_MODE: allow parentheses in AI data if backslashed and

in `ESCAPE_MODE`
composite: empty primary now returns `ZINT_ERROR_INVALID_DATA`
  rather than `ZINT_ERROR_INVALID_OPTION`;
  check that primary NUL-terminated
library: check that `outfile` NUL-terminated
gs1: preface all routines and linters with "gs1_"
general: some code fiddling
This commit is contained in:
gitlost 2025-04-24 18:40:50 +01:00
parent 51ebca182c
commit fcb3f9b422
29 changed files with 1586 additions and 1184 deletions

View file

@ -1320,7 +1320,7 @@ table below.</p>
<col style="width: 15%" />
<col style="width: 15%" />
<col style="width: 10%" />
<col style="width: 57%" />
<col style="width: 58%" />
</colgroup>
<thead>
<tr>
@ -1404,6 +1404,20 @@ table below.</p>
<td style="text-align: left;">Record Separator</td>
</tr>
<tr>
<td style="text-align: left;"><code>\(</code></td>
<td style="text-align: left;">0x28</td>
<td style="text-align: left;"><code>(</code></td>
<td style="text-align: left;">Opening parenthesis (only with
<code>--gs1parens</code>)</td>
</tr>
<tr>
<td style="text-align: left;"><code>\)</code></td>
<td style="text-align: left;">0x29</td>
<td style="text-align: left;"><code>)</code></td>
<td style="text-align: left;">Closing parenthesis (only with
<code>--gs1parens</code>)</td>
</tr>
<tr>
<td style="text-align: left;"><code>\\</code></td>
<td style="text-align: left;">0x5C</td>
<td style="text-align: left;"><code>\</code></td>
@ -4035,7 +4049,8 @@ sequences.</td>
<td style="text-align: left;"><code>GS1PARENS_MODE</code></td>
<td style="text-align: left;">Parentheses (round brackets) used in GS1
data instead of square brackets to delimit Application Identifiers
(parentheses must not otherwise occur in the data).</td>
(parentheses in the data must be escaped and <code>ESCAPE_MODE</code>
selected).</td>
</tr>
<tr>
<td style="text-align: left;"><code>GS1NOCHECK_MODE</code></td>
@ -5059,11 +5074,13 @@ symbology is defined by the GS1 General Specifications. Application
Identifiers (AIs) should be entered using [square bracket] notation.
These will be converted to parentheses (round brackets) for the Human
Readable Text. This method allows the inclusion of parentheses in the AI
data.</p>
<p>For compatibility with data entry in other systems, if the data does
not include parentheses, the option <code>--gs1parens</code> (API
<code>input_mode |= GS1PARENS_MODE</code>) may be used to signal that
AIs are encased in round brackets instead of square ones.</p>
data without escaping.</p>
<p>For compatibility with data entry in other systems, the option
<code>--gs1parens</code> (API <code>input_mode |= GS1PARENS_MODE</code>)
may be used to signal that AIs are encased in parentheses. If there are
any parentheses in the AI data, they must be escaped with a backslash
(<code>\(</code> or <code>\)</code>) and the option <code>--esc</code>
(API <code>input_mode |= ESCAPE_MODE</code>) selected.</p>
<p>Fixed length data should be entered at the appropriate length for
correct encoding. GS1-128 does not support extended ASCII (ISO/IEC
8859-1) characters. Check digits for GTIN data AI (01) are not generated
@ -5242,10 +5259,10 @@ aria-hidden="true"><code>zint -b DBAR_EXP --compliantheight -d "[01]988987654321
capable of encoding data from a number of AIs in a single symbol. AIs
should be encased in [square brackets] in the input data, which will be
displayed as parentheses (round brackets) in the Human Readable Text.
This method allows the inclusion of parentheses in the AI data. If the
data does not include parentheses, the AIs may alternatively be encased
in parentheses using the <code>--gs1parens</code> switch - see <a
href="#gs1-128">6.1.10.3 GS1-128</a>.</p>
This method allows the inclusion of parentheses in the AI data without
escaping. The AIs may alternatively be encased in parentheses using the
<code>--gs1parens</code> switch - see <a href="#gs1-128">6.1.10.3
GS1-128</a>.</p>
<p>The GTIN-14 data for AI (01) must include the standard GS1 check
digit as this is not calculated by Zint when this symbology is encoded.
Data for fixed-length AIs must be entered at the appropriate length. The
@ -9123,6 +9140,10 @@ are:</p>
\e (0x1B) ESC Escape
\G (0x1D) GS Group Separator
\R (0x1E) RS Record Separator
\( (0x28) ( Opening parenthesis (only with
--gs1parens)
\) (0x29) ) Closing parenthesis (only with
--gs1parens)
\\ (0x5C) \ Backslash
\dNNN (NNN) Any 8-bit character where NNN is
decimal (000-255)
@ -9182,8 +9203,9 @@ should be placed in square brackets <code>"[]"</code> (but see
<dt><code>--gs1parens</code></dt>
<dd>
<p>Process parentheses <code>"()"</code> as GS1 AI delimiters, rather
than square brackets <code>"[]"</code>. The input data must not
otherwise contain parentheses.</p>
than square brackets <code>"[]"</code>. If the AI data contains
parentheses, they must be backslashed (<code>"\("</code> or
<code>"\)"</code>) and the <code>--esc</code> option selected.</p>
</dd>
<dt><code>--gssep</code></dt>
<dd>

View file

@ -521,10 +521,10 @@ Non-printing characters can be entered on the command line using backslash (`\`)
as an escape character in combination with the `--esc` switch. Permissible
sequences are shown in the table below.
---------------------------------------------------------------------------
-----------------------------------------------------------------------------
Escape ASCII Name Interpretation
Sequence Equivalent
---------- ---------- ----- -------------------------------------------
---------- ---------- ----- ---------------------------------------------
`\0` 0x00 `NUL` Null character
`\E` 0x04 `EOT` End of Transmission
@ -549,6 +549,10 @@ Sequence Equivalent
`\R` 0x1E `RS` Record Separator
`\(` 0x28 `(` Opening parenthesis (only with `--gs1parens`)
`\)` 0x29 `)` Closing parenthesis (only with `--gs1parens`)
`\\` 0x5C `\` Backslash
`\dNNN` NNN Any 8-bit character where NNN is decimal
@ -565,7 +569,7 @@ Sequence Equivalent
`\UNNNNNN` Any 21-bit Unicode character where NNNNNN
is hexadecimal (000000-10FFFF)
---------------------------------------------------------------------------
-----------------------------------------------------------------------------
Table: {#tbl:escape_sequences tag=": Escape Sequences"}
@ -2379,7 +2383,8 @@ Value Effect
`GS1PARENS_MODE` Parentheses (round brackets) used in GS1 data instead of
square brackets to delimit Application Identifiers
(parentheses must not otherwise occur in the data).
(parentheses in the data must be escaped and `ESCAPE_MODE`
selected).
`GS1NOCHECK_MODE` Do not check GS1 data for validity, i.e. suppress checks
for valid AIs and data lengths. Invalid characters (e.g.
@ -3322,11 +3327,13 @@ A variation of Code 128 previously known as UCC/EAN-128, this symbology is
defined by the GS1 General Specifications. Application Identifiers (AIs) should
be entered using [square bracket] notation. These will be converted to
parentheses (round brackets) for the Human Readable Text. This method allows the
inclusion of parentheses in the AI data.
inclusion of parentheses in the AI data without escaping.
For compatibility with data entry in other systems, if the data does not include
parentheses, the option `--gs1parens` (API `input_mode |= GS1PARENS_MODE`) may
be used to signal that AIs are encased in round brackets instead of square ones.
For compatibility with data entry in other systems, the option `--gs1parens`
(API `input_mode |= GS1PARENS_MODE`) may be used to signal that AIs are encased
in parentheses. If there are any parentheses in the AI data, they must be
escaped with a backslash (`\(` or `\)`) and the option `--esc` (API `input_mode
|= ESCAPE_MODE`) selected.
Fixed length data should be entered at the appropriate length for correct
encoding. GS1-128 does not support extended ASCII (ISO/IEC 8859-1) characters.
@ -3353,8 +3360,6 @@ digits entered, or a 14-digit number if the standard GS1 check digit is given,
in which case the check digit will be verified. The GS1 check digit (if not
given) and HRT-only AI `"(01)"` are added by Zint.
\clearpage
#### 6.1.10.5 NVE-18 (SSCC-18)
![`zint -b NVE18 --compliantheight -d
@ -3477,9 +3482,8 @@ Previously known as RSS Expanded this is a variable length symbology capable of
encoding data from a number of AIs in a single symbol. AIs should be encased in
[square brackets] in the input data, which will be displayed as parentheses
(round brackets) in the Human Readable Text. This method allows the inclusion of
parentheses in the AI data. If the data does not include parentheses, the AIs
may alternatively be encased in parentheses using the `--gs1parens` switch - see
[6.1.10.3 GS1-128].
parentheses in the AI data without escaping. The AIs may alternatively be
encased in parentheses using the `--gs1parens` switch - see [6.1.10.3 GS1-128].
The GTIN-14 data for AI (01) must include the standard GS1 check digit as this
is not calculated by Zint when this symbology is encoded. Data for fixed-length

View file

@ -676,10 +676,10 @@ Non-printing characters can be entered on the command line using backslash (\)
as an escape character in combination with the --esc switch. Permissible
sequences are shown in the table below.
----------------------------------------------------------------------------
------------------------------------------------------------------------------
Escape ASCII Name Interpretation
Sequence Equivalent
----------- ------------ ------- -------------------------------------------
----------- ------------ ------- ---------------------------------------------
\0 0x00 NUL Null character
\E 0x04 EOT End of Transmission
@ -704,6 +704,10 @@ sequences are shown in the table below.
\R 0x1E RS Record Separator
\( 0x28 ( Opening parenthesis (only with --gs1parens)
\) 0x29 ) Closing parenthesis (only with --gs1parens)
\\ 0x5C \ Backslash
\dNNN NNN Any 8-bit character where NNN is decimal
@ -718,9 +722,9 @@ sequences are shown in the table below.
\uNNNN Any 16-bit Unicode BMP[2] character where
NNNN is hexadecimal (0000-FFFF)
\UNNNNNN Any 21-bit Unicode character where NNNNNN
is hexadecimal (000000-10FFFF)
----------------------------------------------------------------------------
\UNNNNNN Any 21-bit Unicode character where NNNNNN is
hexadecimal (000000-10FFFF)
------------------------------------------------------------------------------
Table : Escape Sequences
@ -2359,7 +2363,8 @@ member. Valid values are shown in the table below.
GS1PARENS_MODE Parentheses (round brackets) used in GS1 data instead of
square brackets to delimit Application Identifiers
(parentheses must not otherwise occur in the data).
(parentheses in the data must be escaped and ESCAPE_MODE
selected).
GS1NOCHECK_MODE Do not check GS1 data for validity, i.e. suppress checks
for valid AIs and data lengths. Invalid characters (e.g.
@ -3198,11 +3203,13 @@ A variation of Code 128 previously known as UCC/EAN-128, this symbology is
defined by the GS1 General Specifications. Application Identifiers (AIs) should
be entered using [square bracket] notation. These will be converted to
parentheses (round brackets) for the Human Readable Text. This method allows the
inclusion of parentheses in the AI data.
inclusion of parentheses in the AI data without escaping.
For compatibility with data entry in other systems, if the data does not include
parentheses, the option --gs1parens (API input_mode |= GS1PARENS_MODE) may be
used to signal that AIs are encased in round brackets instead of square ones.
For compatibility with data entry in other systems, the option --gs1parens (API
input_mode |= GS1PARENS_MODE) may be used to signal that AIs are encased in
parentheses. If there are any parentheses in the AI data, they must be escaped
with a backslash (\( or \)) and the option --esc (API input_mode |= ESCAPE_MODE)
selected.
Fixed length data should be entered at the appropriate length for correct
encoding. GS1-128 does not support extended ASCII (ISO/IEC 8859-1) characters.
@ -3341,9 +3348,8 @@ Previously known as RSS Expanded this is a variable length symbology capable of
encoding data from a number of AIs in a single symbol. AIs should be encased in
[square brackets] in the input data, which will be displayed as parentheses
(round brackets) in the Human Readable Text. This method allows the inclusion of
parentheses in the AI data. If the data does not include parentheses, the AIs
may alternatively be encased in parentheses using the --gs1parens switch - see
6.1.10.3 GS1-128.
parentheses in the AI data without escaping. The AIs may alternatively be
encased in parentheses using the --gs1parens switch - see 6.1.10.3 GS1-128.
The GTIN-14 data for AI (01) must include the standard GS1 check digit as this
is not calculated by Zint when this symbology is encoded. Data for fixed-length
@ -5187,6 +5193,10 @@ OPTIONS
\e (0x1B) ESC Escape
\G (0x1D) GS Group Separator
\R (0x1E) RS Record Separator
\( (0x28) ( Opening parenthesis (only with
--gs1parens)
\) (0x29) ) Closing parenthesis (only with
--gs1parens)
\\ (0x5C) \ Backslash
\dNNN (NNN) Any 8-bit character where NNN is
decimal (000-255)
@ -5239,7 +5249,8 @@ OPTIONS
--gs1parens
Process parentheses "()" as GS1 AI delimiters, rather than square brackets
"[]". The input data must not otherwise contain parentheses.
"[]". If the AI data contains parentheses, they must be backslashed ("\(" or
"\)") and the --esc option selected.
--gssep

View file

@ -180,6 +180,10 @@ The escape sequences are:
\[rs]e (0x1B) ESC Escape
\[rs]G (0x1D) GS Group Separator
\[rs]R (0x1E) RS Record Separator
\[rs]( (0x28) ( Opening parenthesis (only with
\-\-gs1parens)
\[rs]) (0x29) ) Closing parenthesis (only with
\-\-gs1parens)
\[rs]\[rs] (0x5C) \[rs] Backslash
\[rs]dNNN (NNN) Any 8\-bit character where NNN is
decimal (000\-255)
@ -235,7 +239,9 @@ Do not check the validity of GS1 data.
\f[CR]\-\-gs1parens\f[R]
Process parentheses \f[CR]\[dq]()\[dq]\f[R] as GS1 AI delimiters, rather
than square brackets \f[CR]\[dq][]\[dq]\f[R].
The input data must not otherwise contain parentheses.
If the AI data contains parentheses, they must be backslashed
(\f[CR]\[dq]\[rs](\[dq]\f[R] or \f[CR]\[dq]\[rs])\[dq]\f[R]) and the
\f[CR]\-\-esc\f[R] option selected.
.TP
\f[CR]\-\-gssep\f[R]
For Data Matrix in GS1 mode, use \f[CR]GS\f[R] (0x1D) as the GS1 data

View file

@ -160,6 +160,10 @@ Paintbrush (`PCX`), Portable Network Format (`PNG`), Scalable Vector Graphic (`S
\e (0x1B) ESC Escape
\G (0x1D) GS Group Separator
\R (0x1E) RS Record Separator
\( (0x28) ( Opening parenthesis (only with
--gs1parens)
\) (0x29) ) Closing parenthesis (only with
--gs1parens)
\\ (0x5C) \ Backslash
\dNNN (NNN) Any 8-bit character where NNN is
decimal (000-255)
@ -208,8 +212,8 @@ Paintbrush (`PCX`), Portable Network Format (`PNG`), Scalable Vector Graphic (`S
`--gs1parens`
: Process parentheses `"()"` as GS1 AI delimiters, rather than square brackets `"[]"`. The input data must not
otherwise contain parentheses.
: Process parentheses `"()"` as GS1 AI delimiters, rather than square brackets `"[]"`. If the AI data contains
parentheses, they must be backslashed (`"\("` or `"\)"`) and the `--esc` option selected.
`--gssep`