mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-12 22:25:59 -04:00
HANXIN fix wrong func call gb2312_utf8tosb() -> gb18030_utf8tosb()
This commit is contained in:
parent
9b771dba3a
commit
22354a81f1
11 changed files with 80 additions and 64 deletions
|
@ -1,7 +1,7 @@
|
|||
/* gridmtx.c - Grid Matrix
|
||||
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2009-2020 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
|
@ -52,8 +52,8 @@
|
|||
static const char numeral_nondigits[] = " +-.,"; /* Non-digit numeral set, excluding EOL (carriage return/linefeed) */
|
||||
|
||||
/* Whether in numeral or not. If in numeral, *p_numeral_end is set to position after numeral, and *p_numeral_cost is set to per-numeral cost */
|
||||
static int in_numeral(const unsigned int gbdata[], const size_t length, const int posn, unsigned int* p_numeral_end, unsigned int* p_numeral_cost) {
|
||||
int i, digit_cnt, nondigit, nondigit_posn;
|
||||
static int in_numeral(const unsigned int gbdata[], const size_t length, const unsigned int posn, unsigned int* p_numeral_end, unsigned int* p_numeral_cost) {
|
||||
unsigned int i, digit_cnt, nondigit, nondigit_posn;
|
||||
|
||||
if (posn < *p_numeral_end) {
|
||||
return 1;
|
||||
|
@ -128,6 +128,7 @@ static unsigned int head_costs[GM_NUM_MODES] = {
|
|||
};
|
||||
|
||||
static unsigned int* gm_head_costs(unsigned int state[]) {
|
||||
(void)state; /* Unused */
|
||||
return head_costs;
|
||||
}
|
||||
|
||||
|
@ -143,6 +144,7 @@ static unsigned int gm_switch_cost(unsigned int state[], const int k, const int
|
|||
/*B*/ { 4 * GM_MULT, (4 + 2) * GM_MULT, 4 * GM_MULT, 4 * GM_MULT, 4 * GM_MULT, 0 },
|
||||
};
|
||||
|
||||
(void)state; /* Unused */
|
||||
return switch_costs[k][j];
|
||||
}
|
||||
|
||||
|
@ -153,6 +155,7 @@ static unsigned int gm_eod_cost(unsigned int state[], const int k) {
|
|||
13 * GM_MULT, 10 * GM_MULT, 5 * GM_MULT, 5 * GM_MULT, 10 * GM_MULT, 4 * GM_MULT
|
||||
};
|
||||
|
||||
(void)state; /* Unused */
|
||||
return eod_costs[k];
|
||||
}
|
||||
|
||||
|
@ -170,8 +173,8 @@ static void gm_cur_cost(unsigned int state[], const unsigned int gbdata[], const
|
|||
lower = gbdata[i] >= 'a' && gbdata[i] <= 'z';
|
||||
upper = gbdata[i] >= 'A' && gbdata[i] <= 'Z';
|
||||
control = !space && !numeric && !lower && !upper && gbdata[i] < 0x7F; /* Exclude DEL */
|
||||
double_digit = i < length - 1 && numeric && gbdata[i + 1] >= '0' && gbdata[i + 1] <= '9';
|
||||
eol = i < length - 1 && gbdata[i] == 13 && gbdata[i + 1] == 10;
|
||||
double_digit = i < (int) length - 1 && numeric && gbdata[i + 1] >= '0' && gbdata[i + 1] <= '9';
|
||||
eol = i < (int) length - 1 && gbdata[i] == 13 && gbdata[i + 1] == 10;
|
||||
|
||||
/* Hanzi mode can encode anything */
|
||||
cur_costs[GM_H] = prev_costs[GM_H] + (double_digit || eol ? 39 : 78); /* (6.5 : 13) * GM_MULT */
|
||||
|
@ -254,7 +257,8 @@ static int gm_encode(unsigned int gbdata[], const size_t length, char binary[],
|
|||
/* Create a binary stream representation of the input data.
|
||||
7 sets are defined - Chinese characters, Numerals, Lower case letters, Upper case letters,
|
||||
Mixed numerals and latters, Control characters and 8-bit binary data */
|
||||
int sp, current_mode, last_mode;
|
||||
unsigned int sp;
|
||||
int current_mode, last_mode;
|
||||
unsigned int glyph = 0;
|
||||
int c1, c2, done;
|
||||
int p = 0, ppos;
|
||||
|
@ -730,7 +734,7 @@ static void gm_add_ecc(const char binary[], const size_t data_posn, const int la
|
|||
}
|
||||
|
||||
/* Convert from binary stream to 7-bit codewords */
|
||||
for (i = 0; i < data_posn; i++) {
|
||||
for (i = 0; i < (int) data_posn; i++) {
|
||||
for (p = 0; p < 7; p++) {
|
||||
if (binary[i * 7 + p] == '1') {
|
||||
data[i] += (0x40 >> p);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue