mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-15 07:34:35 -04:00
ECI: get_best_eci()
: just assert is_valid_utf8()
as checked
prior to being called manual: update to latest GS1 General Specifications (v24), pandoc (3.1.12.1)
This commit is contained in:
parent
f0d8901d9e
commit
11b3c18aed
8 changed files with 36 additions and 41 deletions
|
@ -1,7 +1,7 @@
|
|||
/* eci.c - Extended Channel Interpretations */
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2009-2024 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
|
@ -764,7 +764,7 @@ INTERNAL int utf8_to_eci(const int eci, const unsigned char source[], unsigned c
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Find the lowest single-byte ECI mode which will encode a given set of Unicode text */
|
||||
/* Find the lowest single-byte ECI mode which will encode a given set of Unicode text, assuming valid UTF-8 */
|
||||
INTERNAL int get_best_eci(const unsigned char source[], int length) {
|
||||
int eci = 3;
|
||||
/* Note: attempting single-byte conversions only, so get_eci_length() unnecessary */
|
||||
|
@ -782,14 +782,12 @@ INTERNAL int get_best_eci(const unsigned char source[], int length) {
|
|||
eci++;
|
||||
} while (eci < 25);
|
||||
|
||||
if (!is_valid_utf8(source, length)) {
|
||||
return 0;
|
||||
}
|
||||
assert(is_valid_utf8(source, length));
|
||||
|
||||
return 26; /* If all of these fail, use UTF-8! */
|
||||
}
|
||||
|
||||
/* Call `get_best_eci()` for each segment. Returns 0 on failure, first ECI set on success */
|
||||
/* Call `get_best_eci()` for each segment, assuming valid UTF-8. Returns 0 on failure, first ECI set on success */
|
||||
INTERNAL int get_best_eci_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count) {
|
||||
const int default_eci = symbol->symbology == BARCODE_GRIDMATRIX ? 29 : symbol->symbology == BARCODE_UPNQR ? 4 : 3;
|
||||
int first_eci_set = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue