CODE128: optimize for extended ASCII as well using techniques from

BWIPP minimal encoding by Bue Jensen (BWIPP PR #278);
  new extra escape `\^@` to turn off manual switching
zint.h: increase `symbol->text` size 200 -> 256 (means that for
  the moment can no longer generate ZINT_WARN_HRT_TRUNCATED)
GS1_128/GS1_128_CC: warn if READER_INIT option used
CODE16K: move `c16k_set_a/b/c()` routines from "code128.c" and
  rename `c16k_` (also `C128_` defines to `C16K_`)
common: make `itoc()` simple macro which adds '0' (>= 10 now ':',
  ';' etc) and adjust `expand()` accordingly for slight speed-up
general: EXTRA_ESCAPE_MODE now implies ESCAPE_MODE
tests: update BWIPP to latest and enable CODE128AB ("suppressc");
  new test args '-n' (exclude func) and '-m' (match func)
This commit is contained in:
gitlost 2024-11-18 05:08:52 +00:00
parent c9909d3d91
commit 86b6a0553b
23 changed files with 1113 additions and 1017 deletions

View file

@ -332,7 +332,7 @@
<h1 class="title">Zint Barcode Generator and Zint Barcode Studio User
Manual</h1>
<p class="author">Version 2.13.0.9</p>
<p class="date">October 2024</p>
<p class="date">November 2024</p>
</header>
<nav id="TOC" role="doc-toc">
<ul>
@ -3679,7 +3679,7 @@ data-tag=": API Warning and Error Return Values">
<tr>
<td style="text-align: left;"><code>ZINT_WARN_HRT_TRUNCATED</code></td>
<td style="text-align: left;">The Human Readable Text returned in
<code>text</code> was truncated (maximum 199 bytes).</td>
<code>text</code> was truncated (maximum 255 bytes).</td>
</tr>
<tr>
<td style="text-align: left;"><code>ZINT_WARN_INVALID_OPTION</code></td>
@ -4816,21 +4816,27 @@ aria-hidden="true"><code>zint -b CODE128 --bind -d "130170X178"</code></figcapti
128 was developed in 1981 by Computer Identics. This symbology supports
full ASCII text and uses a three-Code Set system to compress the data
into a smaller symbol. Zint automatically switches between Code Sets A,
B and C (but see following) and adds a hidden modulo-103 check
digit.</p>
B and C (but see below) and adds a hidden modulo-103 check digit.</p>
<p>Code 128 is the default barcode symbology used by Zint. In addition
Zint supports the encoding of ISO/IEC 8859-1 (non-English) characters in
Code 128 symbols. The ISO/IEC 8859-1 character set is shown in Annex <a
href="#a.2-latin-alphabet-no.-1-isoiec-8859-1">A.2 Latin Alphabet No. 1
(ISO/IEC 8859-1)</a>.</p>
<p>Manual switching of Code Sets is possible using the
<code>--extraesc</code> option (API
<code>input_mode |= EXTRA_ESCAPE_MODE</code>) and the Code 128-specific
escapes <code>\^A</code>, <code>\^B</code>, <code>\^C</code>. For
<code>input_mode |= EXTRA_ESCAPE_MODE</code>), which apart from
processing normal escape sequences also processes the Code 128-specific
escapes <code>\^A</code>, <code>\^B</code>, <code>\^C</code> and
<code>\^@</code> (the latter turns off manual Code Set selection). For
instance the following will force switching to Code Set B for the data
<code>"5678"</code> (normally Code Set C would be used throughout):</p>
<div class="sourceCode" id="cb99"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb99-1"><a href="#cb99-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> CODE128 <span class="at">-d</span> <span class="st">&quot;1234\^B5678&quot;</span> <span class="at">--extraesc</span></span></code></pre></div>
<p>The manually selected Code Set will apply until the next Code Set
escape sequence, with the exception that data that cannot be represented
in that Code Set will be switched as appropriate. If the data contains a
special code sequence, it can be escaped by doubling the caret
(<code>^</code>). For instance</p>
escape sequence or until a <code>\^@</code>, with the exception that
data that cannot be represented in that Code Set will be switched as
appropriate. If the data contains an extra escape sequence, it can be
escaped by doubling the caret (<code>^</code>). For instance</p>
<div class="sourceCode" id="cb100"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb100-1"><a href="#cb100-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> CODE128 <span class="at">-d</span> <span class="st">&quot;\^AABC\^^BDEF&quot;</span> <span class="at">--extraesc</span></span></code></pre></div>
<p>will encode the data <code>"ABC\^BDEF"</code> in Code Set A.</p>
@ -4839,13 +4845,9 @@ special Function Code 1 character (FNC1) anywhere you chose in the data,
for instance</p>
<div class="sourceCode" id="cb101"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb101-1"><a href="#cb101-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> CODE128 <span class="at">-d</span> <span class="st">&quot;A\^1BC\^1DEF&quot;</span> <span class="at">--extraesc</span></span></code></pre></div>
<p>Code 128 is the default barcode symbology used by Zint. In addition
Zint supports the encoding of ISO/IEC 8859-1 (non-English) characters in
Code 128 symbols. The ISO/IEC 8859-1 character set is shown in Annex <a
href="#a.2-latin-alphabet-no.-1-isoiec-8859-1">A.2 Latin Alphabet No. 1
(ISO/IEC 8859-1)</a>.</p>
<p>Zint can encode a maximum of 99 symbol characters, which allows for
e.g. 198 all-numeric characters.</p>
<p>Zint can encode a maximum of 102 symbol characters, which allows for
e.g. 202 all-numeric or 101 all-uppercase characters. Sizes above 120
digits (60 alphanumerics) are not recommended.</p>
<h4 id="code-128-suppress-code-set-c-code-sets-a-and-b-only">6.1.10.2
Code 128 Suppress Code Set C (Code Sets A and B only)</h4>
<figure>
@ -8900,12 +8902,14 @@ are:</p>
</dd>
<dt><code>--extraesc</code></dt>
<dd>
<p>For Code 128 only, process the special escape sequences
<code>\^A</code>, <code>\^B</code> and <code>\^C</code> that allow
<p>For Code 128 only, as well as processing the normal escape sequences
above, process the special escape sequences <code>\^A</code>,
<code>\^B</code>, <code>\^C</code> and <code>\^@</code> that allow
manual switching of Code Sets, and the special escape sequence
<code>\^1</code> that inserts an <code>FNC1</code> character. The
sequence <code>\^^</code> can be used to encode data that contains
special escape sequences.</p>
sequence <code>\@</code> turns off manual switching. The sequence
<code>\^^</code> can be used to encode data that contains special escape
sequences.</p>
</dd>
<dt><code>--fast</code></dt>
<dd>

View file

@ -1,6 +1,6 @@
% Zint Barcode Generator and Zint Barcode Studio User Manual
% Version 2.13.0.9
% October 2024
% November 2024
# 1. Introduction
@ -1893,12 +1893,12 @@ int main(int argc, char **argv)
{
struct zint_symbol *my_symbol;
my_symbol = ZBarcode_Create();
my_symbol->output_options |= BARCODE_MEMORY_FILE;
/* Only the extension is used, to determine output format */
strcpy(my_symbol->outfile, "mem.svg");
my_symbol->output_options |= BARCODE_MEMORY_FILE;
/* Only the extension is used, to determine output format */
strcpy(my_symbol->outfile, "mem.svg");
ZBarcode_Encode_and_Print(my_symbol, argv[1], 0, 0);
/* `my_symbol->memfile` now contains the SVG output */
fwrite(my_symbol->memfile, 1, my_symbol->memfile_size, stdout);
/* `my_symbol->memfile` now contains the SVG output */
fwrite(my_symbol->memfile, 1, my_symbol->memfile_size, stdout);
ZBarcode_Delete(my_symbol);
return 0;
}
@ -2143,7 +2143,7 @@ detailing the nature of the error. The errors generated by Zint are:
Return Value Meaning
----------------------------- -----------------------------------------------
`ZINT_WARN_HRT_TRUNCATED` The Human Readable Text returned in `text` was
truncated (maximum 199 bytes).
truncated (maximum 255 bytes).
`ZINT_WARN_INVALID_OPTION` One of the values in `zint_struct` was set
incorrectly but Zint has made a guess at what
@ -3109,22 +3109,30 @@ pharmaceuticals. The symbology is able to encode whole numbers between 3 and
One of the most ubiquitous one-dimensional barcode symbologies, Code 128 was
developed in 1981 by Computer Identics. This symbology supports full ASCII text
and uses a three-Code Set system to compress the data into a smaller symbol.
Zint automatically switches between Code Sets A, B and C (but see following) and
Zint automatically switches between Code Sets A, B and C (but see below) and
adds a hidden modulo-103 check digit.
Code 128 is the default barcode symbology used by Zint. In addition Zint
supports the encoding of ISO/IEC 8859-1 (non-English) characters in Code 128
symbols. The ISO/IEC 8859-1 character set is shown in Annex [A.2 Latin Alphabet
No. 1 (ISO/IEC 8859-1)].
Manual switching of Code Sets is possible using the `--extraesc` option (API
`input_mode |= EXTRA_ESCAPE_MODE`) and the Code 128-specific escapes `\^A`,
`\^B`, `\^C`. For instance the following will force switching to Code Set B for
the data `"5678"` (normally Code Set C would be used throughout):
`input_mode |= EXTRA_ESCAPE_MODE`), which apart from processing normal escape
sequences also processes the Code 128-specific escapes `\^A`, `\^B`, `\^C` and
`\^@` (the latter turns off manual Code Set selection). For instance the
following will force switching to Code Set B for the data `"5678"` (normally
Code Set C would be used throughout):
```bash
zint -b CODE128 -d "1234\^B5678" --extraesc
```
The manually selected Code Set will apply until the next Code Set escape
sequence, with the exception that data that cannot be represented in that Code
Set will be switched as appropriate. If the data contains a special code
sequence, it can be escaped by doubling the caret (`^`). For instance
sequence or until a `\^@`, with the exception that data that cannot be
represented in that Code Set will be switched as appropriate. If the data
contains an extra escape sequence, it can be escaped by doubling the caret
(`^`). For instance
```bash
zint -b CODE128 -d "\^AABC\^^BDEF" --extraesc
@ -3139,13 +3147,9 @@ There is also the extra escape `\^1`, which will encode a special Function Code
zint -b CODE128 -d "A\^1BC\^1DEF" --extraesc
```
Code 128 is the default barcode symbology used by Zint. In addition Zint
supports the encoding of ISO/IEC 8859-1 (non-English) characters in Code 128
symbols. The ISO/IEC 8859-1 character set is shown in Annex [A.2 Latin Alphabet
No. 1 (ISO/IEC 8859-1)].
Zint can encode a maximum of 99 symbol characters, which allows for e.g. 198
all-numeric characters.
Zint can encode a maximum of 102 symbol characters, which allows for e.g. 202
all-numeric or 101 all-uppercase characters. Sizes above 120 digits (60
alphanumerics) are not recommended.
#### 6.1.10.2 Code 128 Suppress Code Set C (Code Sets A and B only)

View file

@ -1,6 +1,6 @@
Zint Barcode Generator and Zint Barcode Studio User Manual
Version 2.13.0.9
October 2024
November 2024
*******************************************************************************
* For reference the following is a text-only version of the Zint manual, *
@ -2143,7 +2143,7 @@ the nature of the error. The errors generated by Zint are:
Return Value Meaning
------------------------------ -----------------------------------------------
ZINT_WARN_HRT_TRUNCATED The Human Readable Text returned in text was
truncated (maximum 199 bytes).
truncated (maximum 255 bytes).
ZINT_WARN_INVALID_OPTION One of the values in zint_struct was set
incorrectly but Zint has made a guess at what
@ -3011,20 +3011,27 @@ pharmaceuticals. The symbology is able to encode whole numbers between 3 and
One of the most ubiquitous one-dimensional barcode symbologies, Code 128 was
developed in 1981 by Computer Identics. This symbology supports full ASCII text
and uses a three-Code Set system to compress the data into a smaller symbol.
Zint automatically switches between Code Sets A, B and C (but see following) and
Zint automatically switches between Code Sets A, B and C (but see below) and
adds a hidden modulo-103 check digit.
Code 128 is the default barcode symbology used by Zint. In addition Zint
supports the encoding of ISO/IEC 8859-1 (non-English) characters in Code 128
symbols. The ISO/IEC 8859-1 character set is shown in Annex A.2 Latin Alphabet
No. 1 (ISO/IEC 8859-1).
Manual switching of Code Sets is possible using the --extraesc option (API
input_mode |= EXTRA_ESCAPE_MODE) and the Code 128-specific escapes \^A, \^B,
\^C. For instance the following will force switching to Code Set B for the data
"5678" (normally Code Set C would be used throughout):
input_mode |= EXTRA_ESCAPE_MODE), which apart from processing normal escape
sequences also processes the Code 128-specific escapes \^A, \^B, \^C and \^@
(the latter turns off manual Code Set selection). For instance the following
will force switching to Code Set B for the data "5678" (normally Code Set C
would be used throughout):
zint -b CODE128 -d "1234\^B5678" --extraesc
The manually selected Code Set will apply until the next Code Set escape
sequence, with the exception that data that cannot be represented in that Code
Set will be switched as appropriate. If the data contains a special code
sequence, it can be escaped by doubling the caret (^). For instance
sequence or until a \^@, with the exception that data that cannot be represented
in that Code Set will be switched as appropriate. If the data contains an extra
escape sequence, it can be escaped by doubling the caret (^). For instance
zint -b CODE128 -d "\^AABC\^^BDEF" --extraesc
@ -3035,13 +3042,9 @@ character (FNC1) anywhere you chose in the data, for instance
zint -b CODE128 -d "A\^1BC\^1DEF" --extraesc
Code 128 is the default barcode symbology used by Zint. In addition Zint
supports the encoding of ISO/IEC 8859-1 (non-English) characters in Code 128
symbols. The ISO/IEC 8859-1 character set is shown in Annex A.2 Latin Alphabet
No. 1 (ISO/IEC 8859-1).
Zint can encode a maximum of 99 symbol characters, which allows for e.g. 198
all-numeric characters.
Zint can encode a maximum of 102 symbol characters, which allows for e.g. 202
all-numeric or 101 all-uppercase characters. Sizes above 120 digits (60
alphanumerics) are not recommended.
6.1.10.2 Code 128 Suppress Code Set C (Code Sets A and B only)
@ -4826,7 +4829,7 @@ configured barcode is displayed once the "Generate" button is pressed.
Annex D. Man Page ZINT(1)
% ZINT(1) Version 2.13.0.9 % % October 2024
% ZINT(1) Version 2.13.0.9 % % November 2024
NAME
@ -5020,10 +5023,11 @@ OPTIONS
--extraesc
For Code 128 only, process the special escape sequences \^A, \^B and \^C
that allow manual switching of Code Sets, and the special escape sequence
\^1 that inserts an FNC1 character. The sequence \^^ can be used to encode
data that contains special escape sequences.
For Code 128 only, as well as processing the normal escape sequences above,
process the special escape sequences \^A, \^B, \^C and \^@ that allow manual
switching of Code Sets, and the special escape sequence \^1 that inserts an
FNC1 character. The sequence \@ turns off manual switching. The sequence \^^
can be used to encode data that contains special escape sequences.
--fast

View file

@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 3.5
.\"
.TH "ZINT" "1" "October 2024" "Version 2.13.0.9"
.TH "ZINT" "1" "November 2024" "Version 2.13.0.9"
.SH NAME
\f[CR]zint\f[R] \- encode data as a barcode image
.SH SYNOPSIS
@ -195,11 +195,13 @@ The escape sequences are:
.RE
.TP
\f[CR]\-\-extraesc\f[R]
For Code 128 only, process the special escape sequences
\f[CR]\[rs]\[ha]A\f[R], \f[CR]\[rs]\[ha]B\f[R] and
\f[CR]\[rs]\[ha]C\f[R] that allow manual switching of Code Sets, and the
special escape sequence \f[CR]\[rs]\[ha]1\f[R] that inserts an
For Code 128 only, as well as processing the normal escape sequences
above, process the special escape sequences \f[CR]\[rs]\[ha]A\f[R],
\f[CR]\[rs]\[ha]B\f[R], \f[CR]\[rs]\[ha]C\f[R] and
\f[CR]\[rs]\[ha]\[at]\f[R] that allow manual switching of Code Sets, and
the special escape sequence \f[CR]\[rs]\[ha]1\f[R] that inserts an
\f[CR]FNC1\f[R] character.
The sequence \f[CR]\[rs]\[at]\f[R] turns off manual switching.
The sequence \f[CR]\[rs]\[ha]\[ha]\f[R] can be used to encode data that
contains special escape sequences.
.TP

View file

@ -1,6 +1,6 @@
% ZINT(1) Version 2.13.0.9
%
% October 2024
% November 2024
# NAME
@ -174,8 +174,9 @@ Paintbrush (`PCX`), Portable Network Format (`PNG`), Scalable Vector Graphic (`S
`--extraesc`
: For Code 128 only, process the special escape sequences `\^A`, `\^B` and `\^C` that allow manual switching of Code
Sets, and the special escape sequence `\^1` that inserts an `FNC1` character. The sequence `\^^` can be used to
: For Code 128 only, as well as processing the normal escape sequences above, process the special escape sequences
`\^A`, `\^B`, `\^C` and `\^@` that allow manual switching of Code Sets, and the special escape sequence `\^1` that
inserts an `FNC1` character. The sequence `\@` turns off manual switching. The sequence `\^^` can be used to
encode data that contains special escape sequences.
`--fast`