mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-29 06:15:23 -04:00
HANXIN: 0xFFE terminator; reedsol/AZTEC: stack-based; AZTEC/HANXIN/QR/GRIDMATRIX speedups; #209
This commit is contained in:
parent
ab379a233d
commit
cd214addba
70 changed files with 5703 additions and 2907 deletions
|
@ -52,14 +52,14 @@
|
|||
* License along with the GNU LIBICONV Library; see the file COPYING.LIB.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <string.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "gb2312.h"
|
||||
|
||||
INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], size_t *length); /* Convert Unicode to other encodings */
|
||||
/* Convert Unicode to other encodings */
|
||||
INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], int *length);
|
||||
|
||||
/*
|
||||
* GB2312.1980-0 (libiconv-1.16/lib/gb2312.h)
|
||||
|
@ -1502,7 +1502,7 @@ static const Summary16 gb2312_uni2indx_pageff[15] = {
|
|||
{ 7441, 0x0000 }, { 7441, 0x0000 }, { 7441, 0x002b },
|
||||
};
|
||||
|
||||
INTERNAL int gb2312_wctomb_zint(unsigned int* r, unsigned int wc) {
|
||||
INTERNAL int gb2312_wctomb_zint(unsigned int *r, unsigned int wc) {
|
||||
const Summary16 *summary = NULL;
|
||||
if (wc < 0x0460) {
|
||||
if (wc == 0x00b7) { /* ZINT: Patched to duplicate map to 0xA1A4 */
|
||||
|
@ -1544,13 +1544,14 @@ INTERNAL int gb2312_wctomb_zint(unsigned int* r, unsigned int wc) {
|
|||
}
|
||||
|
||||
/* Convert UTF-8 string to GB 2312 (EUC-CN) and place in array of ints */
|
||||
INTERNAL int gb2312_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], size_t* p_length, unsigned int* gbdata) {
|
||||
INTERNAL int gb2312_utf8tomb(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
|
||||
unsigned int *gbdata) {
|
||||
int error_number;
|
||||
unsigned int i, length;
|
||||
#ifndef _MSC_VER
|
||||
unsigned int utfdata[*p_length + 1];
|
||||
#else
|
||||
unsigned int* utfdata = (unsigned int*) _alloca((*p_length + 1) * sizeof(unsigned int));
|
||||
unsigned int *utfdata = (unsigned int *) _alloca((*p_length + 1) * sizeof(unsigned int));
|
||||
#endif
|
||||
|
||||
error_number = utf8_to_unicode(symbol, source, utfdata, p_length, 1 /*disallow_4byte*/);
|
||||
|
@ -1573,12 +1574,13 @@ INTERNAL int gb2312_utf8tomb(struct zint_symbol *symbol, const unsigned char sou
|
|||
}
|
||||
|
||||
/* Convert UTF-8 string to single byte ECI and place in array of ints */
|
||||
INTERNAL int gb2312_utf8tosb(int eci, const unsigned char source[], size_t* p_length, unsigned int* gbdata, int full_multibyte) {
|
||||
INTERNAL int gb2312_utf8tosb(int eci, const unsigned char source[], int *p_length, unsigned int *gbdata,
|
||||
int full_multibyte) {
|
||||
int error_number;
|
||||
#ifndef _MSC_VER
|
||||
unsigned char single_byte[*p_length + 1];
|
||||
#else
|
||||
unsigned char* single_byte = (unsigned char*) _alloca(*p_length + 1);
|
||||
unsigned char *single_byte = (unsigned char *) _alloca(*p_length + 1);
|
||||
#endif
|
||||
|
||||
error_number = utf_to_eci(eci, source, single_byte, p_length);
|
||||
|
@ -1592,9 +1594,9 @@ INTERNAL int gb2312_utf8tosb(int eci, const unsigned char source[], size_t* p_le
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* If `full_multibyte` set, copy byte input stream to array of ints, putting double-bytes that match GRIDMATRIX Chinese mode in a single entry.
|
||||
* If `full_multibyte` not set, do a straight copy */
|
||||
INTERNAL void gb2312_cpy(const unsigned char source[], size_t* p_length, unsigned int* gbdata, int full_multibyte) {
|
||||
/* If `full_multibyte` set, copy byte input stream to array of ints, putting double-bytes that match GRIDMATRIX Chinese
|
||||
* mode in a single entry. If `full_multibyte` not set, do a straight copy */
|
||||
INTERNAL void gb2312_cpy(const unsigned char source[], int *p_length, unsigned int *gbdata, int full_multibyte) {
|
||||
unsigned int i, j, length;
|
||||
unsigned char c1, c2;
|
||||
|
||||
|
@ -1604,7 +1606,8 @@ INTERNAL void gb2312_cpy(const unsigned char source[], size_t* p_length, unsigne
|
|||
c1 = source[i];
|
||||
c2 = source[i + 1];
|
||||
if (((c1 >= 0xA1 && c1 <= 0xA9) || (c1 >= 0xB0 && c1 <= 0xF7)) && c2 >= 0xA1 && c2 <= 0xFE) {
|
||||
/* This may or may not be valid GB 2312 (EUC-CN), but don't care as long as it can be encoded in GRIDMATRIX Chinese mode */
|
||||
/* This may or may not be valid GB 2312 (EUC-CN), but don't care as long as it can be encoded in
|
||||
* GRIDMATRIX Chinese mode */
|
||||
gbdata[j] = (c1 << 8) | c2;
|
||||
i++;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue