mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Accept UFT-8 input data for UPNQR
This commit is contained in:
parent
b426877a4f
commit
b46bc1f45e
36
backend/qr.c
36
backend/qr.c
@ -42,6 +42,8 @@
|
|||||||
#include <stdlib.h> /* abs */
|
#include <stdlib.h> /* abs */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
extern int utf_to_eci(int eci, const unsigned char source[], unsigned char dest[], int *length); /* Convert Unicode to other encodings */
|
||||||
|
|
||||||
/* Returns true if input glyph is in the Alphanumeric set */
|
/* Returns true if input glyph is in the Alphanumeric set */
|
||||||
int in_alpha(int glyph) {
|
int in_alpha(int glyph) {
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
@ -2952,7 +2954,7 @@ int microqr(struct zint_symbol *symbol, const unsigned char source[], int length
|
|||||||
int upnqr(struct zint_symbol *symbol, const unsigned char source[], int length) {
|
int upnqr(struct zint_symbol *symbol, const unsigned char source[], int length) {
|
||||||
int i, j, est_binlen;
|
int i, j, est_binlen;
|
||||||
int ecc_level, version, max_cw, target_binlen, blocks, size;
|
int ecc_level, version, max_cw, target_binlen, blocks, size;
|
||||||
int bitmask;
|
int bitmask, error_number;
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
int jisdata[length + 1];
|
int jisdata[length + 1];
|
||||||
@ -2964,23 +2966,35 @@ int upnqr(struct zint_symbol *symbol, const unsigned char source[], int length)
|
|||||||
int* jisdata = (int *) _alloca((length + 1) * sizeof (int));
|
int* jisdata = (int *) _alloca((length + 1) * sizeof (int));
|
||||||
char* mode = (char *) _alloca(length + 1);
|
char* mode = (char *) _alloca(length + 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
unsigned char preprocessed[length + 1];
|
||||||
|
#else
|
||||||
|
unsigned char* preprocessed = (unsigned char*) _alloca(length + 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
switch(symbol->eci) {
|
switch(symbol->input_mode) {
|
||||||
case 3:
|
case DATA_MODE:
|
||||||
/* Convert input to ISO-8859-2 */
|
|
||||||
strcpy(symbol->errtxt, "Not implemented yet!");
|
|
||||||
return ZINT_ERROR_INVALID_DATA;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
/* Input is already in ISO-8859-2 format */
|
/* Input is already in ISO-8859-2 format */
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
jisdata[i] = (int) source[i];
|
jisdata[i] = (int) source[i];
|
||||||
mode[i] = 'B';
|
mode[i] = 'B';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
case GS1_MODE:
|
||||||
strcpy(symbol->errtxt, "Input data should be in Unicode or ISO-8859-2 format");
|
strcpy(symbol->errtxt, "UPNQR does not support GS-1 encoding");
|
||||||
return ZINT_ERROR_INVALID_DATA;
|
return ZINT_ERROR_INVALID_OPTION;
|
||||||
|
break;
|
||||||
|
case UNICODE_MODE:
|
||||||
|
error_number = utf_to_eci(4, source, preprocessed, &length);
|
||||||
|
if (error_number != 0) {
|
||||||
|
strcpy(symbol->errtxt, "Invalid characters in input data (B04)");
|
||||||
|
return error_number;
|
||||||
|
}
|
||||||
|
for (i = 0; i < length; i++) {
|
||||||
|
jisdata[i] = (int) preprocessed[i];
|
||||||
|
mode[i] = 'B';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,6 +320,7 @@ Numeric Value | Barcode Name
|
|||||||
140 | Channel Code
|
140 | Channel Code
|
||||||
141 | Code One
|
141 | Code One
|
||||||
142 | Grid Matrix
|
142 | Grid Matrix
|
||||||
|
143 | UPNQR (Univerzalnega Plačilnega Naloga QR)
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
4.4 Adjusting height
|
4.4 Adjusting height
|
||||||
@ -990,6 +991,7 @@ Value |
|
|||||||
140 | BARCODE_CHANNEL | Channel Code
|
140 | BARCODE_CHANNEL | Channel Code
|
||||||
141 | BARCODE_CODEONE | Code One
|
141 | BARCODE_CODEONE | Code One
|
||||||
142 | BARCODE_GRIDMATRIX | Grid Matrix
|
142 | BARCODE_GRIDMATRIX | Grid Matrix
|
||||||
|
143 | BARCODE_UPNQR | UPNQR (Univerzalnega Plačilnega Naloga QR)
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
5.8 Adjusting other output options
|
5.8 Adjusting other output options
|
||||||
@ -1875,7 +1877,20 @@ Input | Version | Symbol Size
|
|||||||
4 | M4 | 17 x 17
|
4 | M4 | 17 x 17
|
||||||
---------------------------------
|
---------------------------------
|
||||||
|
|
||||||
6.6.4 Maxicode (ISO 16023)
|
6.6.4 UPNQR (Univerzalnega Plačilnega Naloga QR)
|
||||||
|
------------------------------------------------
|
||||||
|
A variation of QR Code used by Združenje Bank Slovenije (Bank Association of
|
||||||
|
Slovenia). The size, error correction level and ECI are set by Zint and do not
|
||||||
|
need to be specified. UPNQR is unusual in that it uses ISO-8859-2 formatted data.
|
||||||
|
Zint will accept UTF-8 data and convert it to ISO-8859-2, or if your data is
|
||||||
|
already ISO-8859-2 formatted use the --binary switch or if using the API set
|
||||||
|
symbol->input_mode = DATA MODE;
|
||||||
|
|
||||||
|
The following example creates a symbol from data saved as an ISO-8859-2 file:
|
||||||
|
|
||||||
|
zint -o upnqr.png -b 143 --border=5 --scale=3 --binary -i ./upn.txt
|
||||||
|
|
||||||
|
6.6.5 Maxicode (ISO 16023)
|
||||||
--------------------------
|
--------------------------
|
||||||
Developed by UPS the Maxicode symbology employs a grid of hexagons surrounding
|
Developed by UPS the Maxicode symbology employs a grid of hexagons surrounding
|
||||||
a 'bulls-eye' finder pattern. This symbology is designed for the identification
|
a 'bulls-eye' finder pattern. This symbology is designed for the identification
|
||||||
@ -1933,7 +1948,7 @@ Mode | Maximum Data Lenth | Maximum Data Length | Number of Error
|
|||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
* - secondary only
|
* - secondary only
|
||||||
|
|
||||||
6.6.5 Aztec Code (ISO 24778)
|
6.6.6 Aztec Code (ISO 24778)
|
||||||
----------------------------
|
----------------------------
|
||||||
Invented by Andrew Longacre at Welch Allyn Inc in 1995 the Aztec Code symbol is
|
Invented by Andrew Longacre at Welch Allyn Inc in 1995 the Aztec Code symbol is
|
||||||
a matrix symbol with a distinctive bulls-eye finder pattern. Zint can generate
|
a matrix symbol with a distinctive bulls-eye finder pattern. Zint can generate
|
||||||
@ -2015,13 +2030,13 @@ A separate symbology ID can be used to encode Health Industry Barcode (HIBC)
|
|||||||
data which adds a leading '+' character and a modulo-49 check digit to the
|
data which adds a leading '+' character and a modulo-49 check digit to the
|
||||||
encoded data.
|
encoded data.
|
||||||
|
|
||||||
6.6.6 Aztec Runes
|
6.6.7 Aztec Runes
|
||||||
-----------------
|
-----------------
|
||||||
A truncated version of compact Aztec Code for encoding whole integers between 0
|
A truncated version of compact Aztec Code for encoding whole integers between 0
|
||||||
and 255. Includes Reed-Solomon error correction. As defined in ISO/IEC 24778
|
and 255. Includes Reed-Solomon error correction. As defined in ISO/IEC 24778
|
||||||
Annex A.
|
Annex A.
|
||||||
|
|
||||||
6.6.7 Code One
|
6.6.8 Code One
|
||||||
--------------
|
--------------
|
||||||
A matrix symbology developed by Ted Williams in 1992 which encodes data in a
|
A matrix symbology developed by Ted Williams in 1992 which encodes data in a
|
||||||
way similar to Data Matrix ECC200. Code One is able to encode the Latin-1
|
way similar to Data Matrix ECC200. Code One is able to encode the Latin-1
|
||||||
@ -2049,7 +2064,7 @@ Input | Version | Size | Numeric | Alphanumeric
|
|||||||
Version S symbols can only encode numeric data. The width of version S and
|
Version S symbols can only encode numeric data. The width of version S and
|
||||||
version T symbols is determined by the length of the input data.
|
version T symbols is determined by the length of the input data.
|
||||||
|
|
||||||
6.6.8 Grid Matrix
|
6.6.9 Grid Matrix
|
||||||
-----------------
|
-----------------
|
||||||
By default Grid Matrix supports encoding in Latin-1 and Chinese characters
|
By default Grid Matrix supports encoding in Latin-1 and Chinese characters
|
||||||
within the GB 2312 standard set to be encoded in a checkerboard pattern. Input
|
within the GB 2312 standard set to be encoded in a checkerboard pattern. Input
|
||||||
@ -2090,7 +2105,7 @@ Mode | Error Correction Capacity
|
|||||||
5 | Approximately 50%
|
5 | Approximately 50%
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
6.6.9 DotCode
|
6.6.10 DotCode
|
||||||
-------------
|
-------------
|
||||||
DotCode uses a grid of dots in a rectangular formation to encode characters up
|
DotCode uses a grid of dots in a rectangular formation to encode characters up
|
||||||
to a maximum of approximately 450 characters (or 900 numeric digits). The
|
to a maximum of approximately 450 characters (or 900 numeric digits). The
|
||||||
@ -2102,7 +2117,7 @@ the image to a larger value than the default (e.g. approx 10) for the dots to
|
|||||||
be plotted correctly. Approximately 33% of the resulting symbol is comprised of
|
be plotted correctly. Approximately 33% of the resulting symbol is comprised of
|
||||||
error correction codewords.
|
error correction codewords.
|
||||||
|
|
||||||
6.6.10 Han Xin Code
|
6.6.11 Han Xin Code
|
||||||
-------------------
|
-------------------
|
||||||
Also known as Chinese Sensible Code, Han Xin is a symbology which is still
|
Also known as Chinese Sensible Code, Han Xin is a symbology which is still
|
||||||
under
|
under
|
||||||
|
Loading…
Reference in New Issue
Block a user