GS1 Syntax Engine
Library for processing GS1 Application Identifier syntax
|
GS1 Syntax Engine
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
The GS1 Syntax Engine provides routines that support the processing of GS1 syntax data, including Application Identifier element strings and GS1 Digital Link URIs, whether these are provided in raw or human-friendly format or as normalised scan data received from barcode readers.
The implementations are intended for use with GS1 standards and applications and do not contain additional features that might be required for more general use.
Within the GS1 Application Identifier system, structured data is represented in different formats depending upon the context.
The data formats supported by this library are:
This following diagram shows how the library can be used for processing and transformation of GS1 data, indicating which formats are accepted as input, how barcode message data is generated and AI data extracted from the provided input data, and how the given data can be output in various formats.
Data transformation: Inputs, outputs and buffers |
---|
The above diagram highlights that conceptually the library contains two internal "data buffers":
The main operations of the library involve reading and updating the state of these buffers.
The following are examples of how to use the library.
Refer to the example console application (gs1encoders-app.c
) for a comprehensive example of how to use this library.
The following code processes AI data input, validates it (reporting any failures) and displays the extracted AIs if the validation succeeds.
In this example we process a bracketed AI element string to convert it into barcode message data, suitable for carrying in a GS1 barcode symbol.
^
represents the FNC1 character. Barcode image encoder libraries will have differing conventions for how to input FNC1 characters, including whether it is necessary to be explicit about the FNC1 character in the first position. The message data output by this library may need to be post-processed to align to the requirements of whatever symbol generation library is in use.In this example we process scan data from a barcode reader to extract the AI data.
Typedefs | |
typedef enum gs1_encoder_symbologies | gs1_encoder_symbologies_t |
Equivalent to the enum gs1_encoder_symbologies type. | |
typedef enum gs1_encoder_validations | gs1_encoder_validations_t |
Equivalent to the enum gs1_encoder_validations type. | |
typedef struct gs1_encoder | gs1_encoder |
A gs1_encoder context. | |
Enumerations | |
enum | gs1_encoder_symbologies { gs1_encoder_sNONE = -1 , gs1_encoder_sDataBarOmni , gs1_encoder_sDataBarTruncated , gs1_encoder_sDataBarStacked , gs1_encoder_sDataBarStackedOmni , gs1_encoder_sDataBarLimited , gs1_encoder_sDataBarExpanded , gs1_encoder_sUPCA , gs1_encoder_sUPCE , gs1_encoder_sEAN13 , gs1_encoder_sEAN8 , gs1_encoder_sGS1_128_CCA , gs1_encoder_sGS1_128_CCC , gs1_encoder_sQR , gs1_encoder_sDM , gs1_encoder_sNUMSYMS } |
Recognised GS1 barcode formats ("symbologies") for processing scan data. More... | |
enum | gs1_encoder_validations { gs1_encoder_vMUTEX_AIS = 0 , gs1_encoder_vREQUISITE_AIS , gs1_encoder_vREPEATED_AIS , gs1_encoder_vDIGSIG_SERIAL_KEY , gs1_encoder_vUNKNOWN_AI_NOT_DL_ATTR , gs1_encoder_vNUMVALIDATIONS } |
Functions | |
GS1_ENCODERS_API char * | gs1_encoder_getVersion (void) |
Get the version string of the library. | |
GS1_ENCODERS_API size_t | gs1_encoder_instanceSize (void) |
Find the memory storage requirements for an instance of gs1_encoder. | |
GS1_ENCODERS_API int | gs1_encoder_getMaxDataStrLength (void) |
Get the maximum size of the input data buffer for barcode message content. | |
GS1_ENCODERS_API gs1_encoder * | gs1_encoder_init (void *mem) |
Initialise a new gs1_encoder context. | |
GS1_ENCODERS_API char * | gs1_encoder_getErrMsg (gs1_encoder *ctx) |
Read an error message generated by the library. | |
GS1_ENCODERS_API char * | gs1_encoder_getErrMarkup (gs1_encoder *ctx) |
Read the error markup generated when parsing AI data fails due to a linting failure. | |
GS1_ENCODERS_API gs1_encoder_symbologies_t | gs1_encoder_getSym (gs1_encoder *ctx) |
Get the current symbology type. | |
GS1_ENCODERS_API bool | gs1_encoder_setSym (gs1_encoder *ctx, gs1_encoder_symbologies_t sym) |
Set the symbology type. | |
GS1_ENCODERS_API bool | gs1_encoder_getAddCheckDigit (gs1_encoder *ctx) |
Get the current status of the "add check digit" mode. | |
GS1_ENCODERS_API bool | gs1_encoder_setAddCheckDigit (gs1_encoder *ctx, bool addCheckDigit) |
Enable or disable "add check digit" mode for EAN/UPC and GS1 DataBar symbols. | |
GS1_ENCODERS_API bool | gs1_encoder_getPermitUnknownAIs (gs1_encoder *ctx) |
Get the current status of the "permit unknown AIs" mode. | |
GS1_ENCODERS_API bool | gs1_encoder_setPermitUnknownAIs (gs1_encoder *ctx, bool permitUnknownAIs) |
Enable or disable "permit unknown AIs" mode for parsing of bracketed AI element strings and GS1 Digital Link URIs. | |
GS1_ENCODERS_API bool | gs1_encoder_getPermitZeroSuppressedGTINinDLuris (gs1_encoder *ctx) |
Get the current status of the "permit zero-suppressed GTIN in GS1 DL URIs" mode. | |
GS1_ENCODERS_API bool | gs1_encoder_setPermitZeroSuppressedGTINinDLuris (gs1_encoder *ctx, bool permitZeroSuppressedGTINinDLuris) |
Enable or disable "permit zero-suppressed GTIN in GS1 DL URIs" mode for parsing of GS1 Digital Link URIs. | |
GS1_ENCODERS_API bool | gs1_encoder_getIncludeDataTitlesInHRI (gs1_encoder *ctx) |
Get the current status of the "include data titles in HRI" flag. | |
GS1_ENCODERS_API bool | gs1_encoder_setIncludeDataTitlesInHRI (gs1_encoder *ctx, bool includeDataTitles) |
Enable or disable "include data titles in HRI" flag. | |
GS1_ENCODERS_API bool | gs1_encoder_getValidationEnabled (gs1_encoder *ctx, gs1_encoder_validations_t validation) |
Get the current enabled status of the provided AI validation procedure. | |
GS1_ENCODERS_API bool | gs1_encoder_setValidationEnabled (gs1_encoder *ctx, gs1_encoder_validations_t validation, bool enabled) |
Enable or disable the given AI validation procedure of type gs1_encoder_validations, that determines whether certain checks are enfored when data is provided using gs1_encoder_setAIdataStr(), gs1_encoder_setDataStr() or gs1_encoder_setScanData(). | |
GS1_ENCODERS_API DEPRECATED bool | gs1_encoder_getValidateAIassociations (gs1_encoder *ctx) |
Provided for backwards compatibility to get the current enabled status of the gs1_encoder_vREQUISITE_AIS validation procedure. | |
GS1_ENCODERS_API DEPRECATED bool | gs1_encoder_setValidateAIassociations (gs1_encoder *ctx, bool validateAIassociations) |
Provided for backwards compatibility to enable or disable the gs1_encoder_vREQUISITE_AIS validation procedure, that determines whether mandatory AI pairings are enfored when data is provided using gs1_encoder_setAIdataStr(), gs1_encoder_setDataStr() or gs1_encoder_setScanData(). | |
GS1_ENCODERS_API char * | gs1_encoder_getDataStr (gs1_encoder *ctx) |
Reads the raw barcode data input buffer. | |
GS1_ENCODERS_API bool | gs1_encoder_setDataStr (gs1_encoder *ctx, const char *dataStr) |
Sets the raw data that would be directly encoded within a GS1 barcode message. | |
GS1_ENCODERS_API bool | gs1_encoder_setAIdataStr (gs1_encoder *ctx, const char *dataStr) |
Sets the data in the buffer that is used when buffer input is selected by parsing input provided in GS1 Application Identifier syntax into a raw data string. | |
GS1_ENCODERS_API char * | gs1_encoder_getAIdataStr (gs1_encoder *ctx) |
Return the barcode input data buffer in human-friendly AI syntax. | |
GS1_ENCODERS_API char * | gs1_encoder_getDLuri (gs1_encoder *ctx, const char *stem) |
Returns a GS1 Digital Link URI representing AI-based input data. | |
GS1_ENCODERS_API bool | gs1_encoder_setScanData (gs1_encoder *ctx, const char *scanData) |
Process normalised scan data received from a barcode reader with reporting of AIM symbology identifiers enabled to extract the message data and perform syntax checks in the case of GS1 Digital Link and AI data input. | |
GS1_ENCODERS_API char * | gs1_encoder_getScanData (gs1_encoder *ctx) |
Returns the string that should be returned by scanners when reading a symbol that is an instance of the selected symbology and contains the same input data. | |
GS1_ENCODERS_API int | gs1_encoder_getHRI (gs1_encoder *ctx, char ***hri) |
Update a given pointer towards an array of strings containing Human-Readable Interpretation ("HRI") text. | |
GS1_ENCODERS_API DEPRECATED size_t | gs1_encoder_getHRIsize (gs1_encoder *ctx) |
Get the require HRI buffer size. | |
GS1_ENCODERS_API DEPRECATED void | gs1_encoder_copyHRI (gs1_encoder *ctx, void *buf, size_t max) |
Copy the HRI to a user-provided buffer in the form of a "|"-separated string. | |
GS1_ENCODERS_API int | gs1_encoder_getDLignoredQueryParams (gs1_encoder *ctx, char ***qp) |
Update a given pointer towards an array of strings containing the non-numeric (ignored) query parameters in a provided GS1 Digital Link URI. | |
GS1_ENCODERS_API DEPRECATED size_t | gs1_encoder_getDLignoredQueryParamsSize (gs1_encoder *ctx) |
Get the require buffer size for ignored GS1 Digital Link query parameters. | |
GS1_ENCODERS_API DEPRECATED void | gs1_encoder_copyDLignoredQueryParams (gs1_encoder *ctx, void *buf, size_t max) |
Copy the non-numeric (ignored) GS1 Digital Link query parameters to a user-provided buffer in the form of a "&"-separated string. | |
GS1_ENCODERS_API void | gs1_encoder_free (gs1_encoder *ctx) |
Destroy a gs1_encoder instance. | |
typedef struct gs1_encoder gs1_encoder |
A gs1_encoder context.
This is an opaque struct that represents an instance of the library.
This context maintains all state required for an instance. Any number of instances of the library can be created, each operating seperately and equivalently to the others.
This library does not introduce any global variables. All runtime state is maintained in instances of the gs1_encoder struct and this state should only be modified using the public API functions provided by this library, decorated with GS1_ENCODERS_API.
A context is created by calling gs1_encoder_init() and destroyed by calling gs1_encoder_free(), releasing all of the storage allocated by the library for that instance.
Recognised GS1 barcode formats ("symbologies") for processing scan data.
Optional AI validation procedures that may be applied to detect invalid inputs when AI data is provided using gs1_encoder_setAIdataStr(), gs1_encoder_setDataStr() or gs1_encoder_setScanData().
GS1_ENCODERS_API DEPRECATED void gs1_encoder_copyDLignoredQueryParams | ( | gs1_encoder * | ctx, |
void * | buf, | ||
size_t | max | ||
) |
Copy the non-numeric (ignored) GS1 Digital Link query parameters to a user-provided buffer in the form of a "&"-separated string.
The buffer into which the output buffer is copied must be preallocated with at least the size returned by gs1_encoder_getDLignoredQueryParamsSize().
[in,out] | ctx | gs1_encoder context |
[out] | buf | a pointer to a buffer into which the formatted non-numeric (ignored) query parameters are copied |
[in] | max | the maximum number of bytes that may be copied into the provided buffer |
GS1_ENCODERS_API DEPRECATED void gs1_encoder_copyHRI | ( | gs1_encoder * | ctx, |
void * | buf, | ||
size_t | max | ||
) |
Copy the HRI to a user-provided buffer in the form of a "|"-separated string.
The buffer into which the output buffer is copied must be preallocated with at least the size returned by gs1_encoder_getHRIsize().
[in,out] | ctx | gs1_encoder context |
[out] | buf | a pointer to a buffer into which the formatted HRI text is copied |
[in] | max | the maximum number of bytes that may be copied into the provided buffer |
GS1_ENCODERS_API void gs1_encoder_free | ( | gs1_encoder * | ctx | ) |
Destroy a gs1_encoder instance.
This will release all library-managed storage associated with the instance.
[in,out] | ctx | gs1_encoder context to destroy |
GS1_ENCODERS_API bool gs1_encoder_getAddCheckDigit | ( | gs1_encoder * | ctx | ) |
Get the current status of the "add check digit" mode.
[in,out] | ctx | gs1_encoder context |
GS1_ENCODERS_API char * gs1_encoder_getAIdataStr | ( | gs1_encoder * | ctx | ) |
Return the barcode input data buffer in human-friendly AI syntax.
For example, if the input data buffer were to contain:
^011231231231233310ABC123|^99XYZ(TM) CORP
Then this function would return:
(01)12312312312333(10)ABC123|(99)XYZ\(TM) CORP
[in,out] | ctx | gs1_encoder context |
GS1_ENCODERS_API char * gs1_encoder_getDataStr | ( | gs1_encoder * | ctx | ) |
Reads the raw barcode data input buffer.
[in,out] | ctx | gs1_encoder context |
GS1_ENCODERS_API int gs1_encoder_getDLignoredQueryParams | ( | gs1_encoder * | ctx, |
char *** | qp | ||
) |
Update a given pointer towards an array of strings containing the non-numeric (ignored) query parameters in a provided GS1 Digital Link URI.
For example, if the input data buffer were to contain:
https://a/01/12312312312333/22/ABC?name=Donald%2dDuck&99=ABC&testing&type=cartoon
Then this function would return the following array of null-terminated strings:
"name=Donald%2dDuck" "testing" "type=cartoon"
[in,out] | ctx | gs1_encoder context |
[out] | qp | Pointer to an array of non-numeric (ignored) query parameters |
GS1_ENCODERS_API DEPRECATED size_t gs1_encoder_getDLignoredQueryParamsSize | ( | gs1_encoder * | ctx | ) |
Get the require buffer size for ignored GS1 Digital Link query parameters.
[in,out] | ctx | gs1_encoder context |
GS1_ENCODERS_API char * gs1_encoder_getDLuri | ( | gs1_encoder * | ctx, |
const char * | stem | ||
) |
Returns a GS1 Digital Link URI representing AI-based input data.
This example use of the library shows how to determine the GS1 Digital Link representation for some bracketed AI data:
[in,out] | ctx | gs1_encoder context |
[in] | stem | a URI "stem" used as a prefix for the URI. If NULL, the GS1 canonical stem (https://id.gs1.org/ ) will be used. |
GS1_ENCODERS_API char * gs1_encoder_getErrMarkup | ( | gs1_encoder * | ctx | ) |
Read the error markup generated when parsing AI data fails due to a linting failure.
When any of the setter functions of this library return false (indicating an error), then if that failure is due to the AI-based data being invalid a marked up instance of the AI that failed will be generated which can be read using this function.
Where it is meaningful to identify offending charaters in the input data, these characters will be surrounded by |
characters. Otherwise the entire AI value will be surrounded by |
characters.
[in,out] | ctx | gs1_encoder context |
GS1_ENCODERS_API char * gs1_encoder_getErrMsg | ( | gs1_encoder * | ctx | ) |
Read an error message generated by the library.
When any of the setter functions of this library return false (indicating an error), a human-friendly error message is generated which can be read using this function.
The library may return a single error message for each data operation. When setting message data with gs1_encoder_setDataStr(), gs1_encoder_setAIdataStr() or gs1_encoder_setScanData() it may be useful to understand the order in which data validation checks are performed.
In general, the data input is validated by applying checks in the following outline sequence:
[in,out] | ctx | gs1_encoder context |
GS1_ENCODERS_API int gs1_encoder_getHRI | ( | gs1_encoder * | ctx, |
char *** | hri | ||
) |
Update a given pointer towards an array of strings containing Human-Readable Interpretation ("HRI") text.
For example, if the input data buffer were to contain:
^011231231231233310ABC123|^99XYZ(TM) CORP
Then this function would return the following array of null-terminated strings:
"(01) 12312312312333" "(10) ABC123" "--" "(99) XYZ(TM) CORP"
[in,out] | ctx | gs1_encoder context |
[out] | hri | Pointer to an array of HRI strings |
GS1_ENCODERS_API DEPRECATED size_t gs1_encoder_getHRIsize | ( | gs1_encoder * | ctx | ) |
Get the require HRI buffer size.
[in,out] | ctx | gs1_encoder context |
GS1_ENCODERS_API bool gs1_encoder_getIncludeDataTitlesInHRI | ( | gs1_encoder * | ctx | ) |
Get the current status of the "include data titles in HRI" flag.
[in,out] | ctx | gs1_encoder context |
GS1_ENCODERS_API int gs1_encoder_getMaxDataStrLength | ( | void | ) |
Get the maximum size of the input data buffer for barcode message content.
This is an implementation limit that may be lowered for systems with limited memory by rebuilding the library.
GS1_ENCODERS_API bool gs1_encoder_getPermitUnknownAIs | ( | gs1_encoder * | ctx | ) |
Get the current status of the "permit unknown AIs" mode.
[in,out] | ctx | gs1_encoder context |
GS1_ENCODERS_API bool gs1_encoder_getPermitZeroSuppressedGTINinDLuris | ( | gs1_encoder * | ctx | ) |
Get the current status of the "permit zero-suppressed GTIN in GS1 DL URIs" mode.
[in,out] | ctx | gs1_encoder context |
GS1_ENCODERS_API char * gs1_encoder_getScanData | ( | gs1_encoder * | ctx | ) |
Returns the string that should be returned by scanners when reading a symbol that is an instance of the selected symbology and contains the same input data.
Examples:
Symbology | Input data | Returned scan data |
---|---|---|
gs1_encoder_sEAN13 | 2112345678900 | ]E02112345678900 |
gs1_encoder_sUPCA | 416000336108 | ]E00416000336108 |
gs1_encoder_sEAN8 | 02345673 | ]E402345673 |
gs1_encoder_sEAN8 | 02345673|^99COMPOSITE^98XYZ | ]E402345673|]e099COMPOSITE{GS}98XYZ |
gs1_encoder_sGS1_128_CCA | ^011231231231233310ABC123^99TESTING | ]C1011231231231233310ABC123{GS}99TESTING |
gs1_encoder_sGS1_128_CCA | ^0112312312312333|^98COMPOSITE^97XYZ | ]e00112312312312333{GS}98COMPOSITE{GS}97XYZ |
gs1_encoder_sQR | https://example.org/01/12312312312333 | ]Q1https://example.org/01/12312312312333 |
gs1_encoder_sQR | ^01123123123123338200http://example.com | ]Q301123123123123338200http://example.com |
gs1_encoder_sDM | https://example.com/gtin/09506000134352/lot/A1 | ]d1https://example.com/gtin/09506000134352/lot/A1 |
gs1_encoder_sDM | ^011231231231233310ABC123^99TESTING | ]d2011231231231233310ABC123{GS}99TESTING |
The output will be prefixed with the appropriate AIM symbology identifier.
"{GS}" in the scan data output in the above table represents a literal GS character (ASCII 29) that is included in the returned data.
The literal "|" character included in the scan data output for EAN/UPC Composite symbols indicates the separation between the first and second messages that would be transmitted by a reader that is configured to return the composite component.
This example use of the library shows how to determine what data a scanner should provide when reading a certain symbol:
[in,out] | ctx | gs1_encoder context |
GS1_ENCODERS_API gs1_encoder_symbologies_t gs1_encoder_getSym | ( | gs1_encoder * | ctx | ) |
Get the current symbology type.
[in,out] | ctx | gs1_encoder context |
GS1_ENCODERS_API DEPRECATED bool gs1_encoder_getValidateAIassociations | ( | gs1_encoder * | ctx | ) |
Provided for backwards compatibility to get the current enabled status of the gs1_encoder_vREQUISITE_AIS validation procedure.
gs1_encoder_getValidationEnabled(ctx,
gs1_encoder_vREQUISITE_AIS)
, which should be called instead.[in,out] | ctx | gs1_encoder context |
GS1_ENCODERS_API bool gs1_encoder_getValidationEnabled | ( | gs1_encoder * | ctx, |
gs1_encoder_validations_t | validation | ||
) |
Get the current enabled status of the provided AI validation procedure.
[in,out] | ctx | gs1_encoder context |
[in] | validation | a validation procedure of type gs1_encoder_validations to check the status of |
GS1_ENCODERS_API char * gs1_encoder_getVersion | ( | void | ) |
Get the version string of the library.
This is typically the build date.
The return data does not need to be free()ed.
GS1_ENCODERS_API gs1_encoder * gs1_encoder_init | ( | void * | mem | ) |
Initialise a new gs1_encoder context.
If it expected that most users of the library will pass NULL to this function which causes the library will allocate its own storage.
If a pointer to a storage buffer is provided then this will be used instead, however this buffer must be sufficient for the needs of the instance as returned by gs1_encoder_instanceSize() and this buffer should not be reused or freed until gs1_encoder_free() is called.
[in,out] | mem | buffer to use for storage, or NULL for automatic allocation |
GS1_ENCODERS_API size_t gs1_encoder_instanceSize | ( | void | ) |
Find the memory storage requirements for an instance of gs1_encoder.
For embedded systems it may be desirable to provide a pre-allocated buffer to a new context for storage purposes, rather than to have the instance malloc() it's own storage. This may avoid problems such as heap fragmentation on systems with a poor memory allocator or a restricted working set size.
This function returns the minimum size required for such a buffer.
Example of a user of the library allocating its own heap storage:
Example of a user of the library using static storage allocated at compile time:
GS1_ENCODERS_API bool gs1_encoder_setAddCheckDigit | ( | gs1_encoder * | ctx, |
bool | addCheckDigit | ||
) |
Enable or disable "add check digit" mode for EAN/UPC and GS1 DataBar symbols.
[in,out] | ctx | gs1_encoder context |
[in] | addCheckDigit | enabled if true; disabled if false |
GS1_ENCODERS_API bool gs1_encoder_setAIdataStr | ( | gs1_encoder * | ctx, |
const char * | dataStr | ||
) |
Sets the data in the buffer that is used when buffer input is selected by parsing input provided in GS1 Application Identifier syntax into a raw data string.
The input is provided in human-friendly format without FNC1 characters which are inserted automatically, for example:
This syntax harmonises the format for the input accepted by all symbologies. For example the following input is acceptable for EAN-13, UPC-A, UPC-E, any variant of the GS1 DataBar family, GS1 QR Code and GS1 DataMatrix:
The input is immediately parsed and validated against certain rules for GS1 AIs, after which the resulting encoding for valid inputs is available via gs1_encoder_getDataStr(). If the input is invalid then this function will return false and an error message will be set that can be read using gs1_encoder_getErrMsg().
Any "(" characters in AI element values must be escaped as "\(" to avoid conflating them with the start of the next AI.
For symbologies that support a composite component (all except gs1_encoder_sDM and gs1_encoder_sQR), the data for the linear and 2D components can be separated by a "|" character, for example:
[in,out] | ctx | gs1_encoder context |
[in] | dataStr | the barcode input data in GS1 Application Identifier syntax |
GS1_ENCODERS_API bool gs1_encoder_setDataStr | ( | gs1_encoder * | ctx, |
const char * | dataStr | ||
) |
Sets the raw data that would be directly encoded within a GS1 barcode message.
A "^" character at the start of the input indicates that the data is in GS1 Application Identifier syntax. In this case, all subsequent instances of the "^" character represent the FNC1 non-data characters that are used to separate fields that are not specified as being pre-defined length from subsequent fields.
Inputs beginning with "^" will be validated against certain data syntax rules for GS1 AIs. If the input is invalid then this function will return false and an error message will be set that can be read using gs1_encoder_getErrMsg(). In the case that the data is unacceptable due to invalid AI content then a marked up version of the offending AI can be retrieved using gs1_encoder_getErrMarkup().
It is strongly advised that GS1 data input is instead specified using gs1_encoder_setAIdataStr() which takes care of the AI encoding rules automatically, including insertion of FNC1 characters where required. This can be used for all symbologies that accept GS1 AI syntax data.
Inputs beginning with "http://" or "https://" will be parsed as a GS1 Digital Link URI during which the corresponding AI element string is extracted and validated.
EAN/UPC, GS1 DataBar and GS1-128 support a Composite Component. The Composite Component must be specified in AI syntax. It must be separated from the primary linear components with a "|" character and begin with an FNC1 in first position, for example:
The above specifies a linear component representing "(01)12345678901231" together with a composite component representing "(10)ABC123(11)210630".
Again, for GS1 data it is simpler and less error prone to specify the input in human-friendly GS1 AI syntax using gs1_encoder_setAIdataStr().
[in,out] | ctx | gs1_encoder context |
[in] | dataStr | containing the raw barcode data |
GS1_ENCODERS_API bool gs1_encoder_setIncludeDataTitlesInHRI | ( | gs1_encoder * | ctx, |
bool | includeDataTitles | ||
) |
Enable or disable "include data titles in HRI" flag.
[in,out] | ctx | gs1_encoder context |
[in] | includeDataTitles | enabled if true; disabled if false |
GS1_ENCODERS_API bool gs1_encoder_setPermitUnknownAIs | ( | gs1_encoder * | ctx, |
bool | permitUnknownAIs | ||
) |
Enable or disable "permit unknown AIs" mode for parsing of bracketed AI element strings and GS1 Digital Link URIs.
[in,out] | ctx | gs1_encoder context |
[in] | permitUnknownAIs | enabled if true; disabled if false |
GS1_ENCODERS_API bool gs1_encoder_setPermitZeroSuppressedGTINinDLuris | ( | gs1_encoder * | ctx, |
bool | permitZeroSuppressedGTINinDLuris | ||
) |
Enable or disable "permit zero-suppressed GTIN in GS1 DL URIs" mode for parsing of GS1 Digital Link URIs.
[in,out] | ctx | gs1_encoder context |
[in] | permitZeroSuppressedGTINinDLuris | enabled if true; disabled if false |
GS1_ENCODERS_API bool gs1_encoder_setScanData | ( | gs1_encoder * | ctx, |
const char * | scanData | ||
) |
Process normalised scan data received from a barcode reader with reporting of AIM symbology identifiers enabled to extract the message data and perform syntax checks in the case of GS1 Digital Link and AI data input.
This function will process scan data (such as the output of a barcode reader) and process the received data, setting the data input buffer to the message received and setting the selected symbology to something that is able to carry the received data.
A literal "|" character may be included in the scan data to indicates the separation between the first and second messages that would be transmitted by a reader that is configured to return the composite component when reading EAN/UPC symbols.
This example use of the library processes a given scan data string, which is assumed to represent AI data in this instance, and then renders the AI data in human-friendly format.
[in,out] | ctx | gs1_encoder context |
[in] | scanData | the scan data input as read by a reader with AIM symbology identifiers enabled |
GS1_ENCODERS_API bool gs1_encoder_setSym | ( | gs1_encoder * | ctx, |
gs1_encoder_symbologies_t | sym | ||
) |
Set the symbology type.
This allows the symbology to be specified as any one of the described gs1_encoder_symbologies
[in,out] | ctx | gs1_encoder context |
[in] | sym | symbology type |
GS1_ENCODERS_API DEPRECATED bool gs1_encoder_setValidateAIassociations | ( | gs1_encoder * | ctx, |
bool | validateAIassociations | ||
) |
Provided for backwards compatibility to enable or disable the gs1_encoder_vREQUISITE_AIS validation procedure, that determines whether mandatory AI pairings are enfored when data is provided using gs1_encoder_setAIdataStr(), gs1_encoder_setDataStr() or gs1_encoder_setScanData().
gs1_encoder_setValidationEnabled(ctx,
gs1_encoder_vREQUISITE_AIS, enabled)
, which should be called instead.[in,out] | ctx | gs1_encoder context |
[in] | validateAIassociations | enable the gs1_encoder_vREQUISITE_AIS validation procedure if true; otherwise disable |
GS1_ENCODERS_API bool gs1_encoder_setValidationEnabled | ( | gs1_encoder * | ctx, |
gs1_encoder_validations_t | validation, | ||
bool | enabled | ||
) |
Enable or disable the given AI validation procedure of type gs1_encoder_validations, that determines whether certain checks are enfored when data is provided using gs1_encoder_setAIdataStr(), gs1_encoder_setDataStr() or gs1_encoder_setScanData().
Nevertheless, the full AI data should be validated by concatinating it and verifying it with this library with all relivant AI validation procedures enabled.
[in,out] | ctx | gs1_encoder context |
[in] | validation | a validation procedure of type gs1_encoder_validations to attempt to set the enabled status of |
[in] | enabled | validation is enabled if true; disabled if false |