HANXIN ECI conversion, GB 18030 LIBICONV port; some codeword fixes; optimized encoding modes

This commit is contained in:
gitlost 2019-12-08 16:15:34 +00:00
parent ce8aa92846
commit 889e786d95
35 changed files with 67955 additions and 23877 deletions

View file

@ -4,6 +4,20 @@
libzint - the open source barcode library
Copyright (C) 2008-2019 Robin Stuart <rstuart114@gmail.com>
*/
/* To create backend/tests/test_sjis_tab.h (from backend/tests/build directory):
*
* php ../tools/gen_test_tab.php
*
* To create backend/tests/test_gb2312_tab.h;
*
* php ../tools/gen_test_tab.php -f GB2312.TXT -s gb2312_tab
*
* To create backend/tests/test_gb18030_tab.h (note that backend/tests/tools/data/GB18030.TXT
* will have to be downloaded first from https://haible.de/bruno/charsets/conversion-tables/GB18030.html
* using the version libiconv-1.11/GB18030.TXT):
*
* php ../tools/gen_test_tab.php -f GB18030.TXT -s gb18030_tab
*/
/* vim: set ts=4 sw=4 et : */
$basename = basename(__FILE__);
@ -35,7 +49,10 @@ foreach ($lines as $line) {
if ($line === '' || strncmp($line, '0x', 2) !== 0) {
continue;
}
$tab_lines[] = preg_replace_callback('/^0x([0-9A-F]{2,4})[ \t]+0x([0-9A-F]{4}).*$/', function ($matches) {
if (preg_match('/^0x([0-9A-F]{2,8})[ \t]+0x([0-9A-F]{5})/', $line)) { // Exclude U+10000..10FFFF to save space
continue;
}
$tab_lines[] = preg_replace_callback('/^0x([0-9A-F]{2,8})[ \t]+0x([0-9A-F]{4}).*$/', function ($matches) {
global $sort;
$mb = hexdec($matches[1]);
$unicode = hexdec($matches[2]);
@ -50,8 +67,20 @@ array_multisort($sort, $tab_lines);
$out = array();
$out[] = '/* Generated by ' . $basename . ' from ' . $file_name . ' */';
$out[] = 'static const unsigned short test_' . $suffix_name . '[] = {';
$out[] = 'static const unsigned int test_' . $suffix_name . '[] = {';
$out = array_merge($out, $tab_lines);
$out[] = '};';
$out[] = '';
$out[] = 'static const unsigned int test_' . $suffix_name . '_ind[] = {';
$first = 0;
foreach ($sort as $ind => $unicode) {
$div = (int)($unicode / 0x1000);
while ($div >= $first) {
$out[] = ($ind * 2) . ',';
$first++;
}
}
$out[] = '};';
file_put_contents($out_dirname . '/test_' . $suffix_name . '.h', implode("\n", $out) . "\n");