mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-28 05:54:19 -04:00
ECI conversion for GRIDMATRIX; GB 2312 LIBICONV port
This commit is contained in:
parent
fed7378675
commit
8be13283db
17 changed files with 17010 additions and 7527 deletions
25
backend/tools/cnv_gb2312.php
Normal file
25
backend/tools/cnv_gb2312.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
/* Convert libiconv-1.16/lib/gb2312.h to EUC-CN values (+ 0x8080). */
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2008-2019 Robin Stuart <rstuart114@gmail.com>
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
$in = false;
|
||||
while ($line = fgets(STDIN)) {
|
||||
if ($in) {
|
||||
if (strncmp($line, '};', 2) === 0) {
|
||||
echo $line;
|
||||
break;
|
||||
}
|
||||
echo preg_replace_callback('/0x([0-9a-f]{4})/', function ($matches) {
|
||||
return '0x' . dechex(hexdec($matches[1]) + 0x8080);
|
||||
}, $line);
|
||||
} else {
|
||||
if (strpos($line, 'short gb2312_2charset') !== false) {
|
||||
echo $line;
|
||||
$in = true;
|
||||
}
|
||||
}
|
||||
}
|
31
backend/tools/cnv_sjis.php
Normal file
31
backend/tools/cnv_sjis.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/* Convert libiconv-1.16/lib/jisx0208.h to Shift JIS values. */
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2008-2019 Robin Stuart <rstuart114@gmail.com>
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
$in = false;
|
||||
while ($line = fgets(STDIN)) {
|
||||
if ($in) {
|
||||
if (strncmp($line, '};', 2) === 0) {
|
||||
echo $line;
|
||||
break;
|
||||
}
|
||||
echo preg_replace_callback('/0x([0-9a-f]{4})/', function ($matches) {
|
||||
$dec = hexdec($matches[1]);
|
||||
$c1 = $dec >> 8;
|
||||
$c2 = ($dec & 0xFF);
|
||||
$t1 = ($c1 - 0x21) >> 1;
|
||||
$t2 = ((($c1 - 0x21) & 1) ? 0x5e : 0) + ($c2 - 0x21);
|
||||
$r = (($t1 < 0x1f ? ($t1 + 0x81) : ($t1 + 0xc1)) << 8) | ($t2 < 0x3f ? ($t2 + 0x40) : ($t2 + 0x41));
|
||||
return '0x' . dechex($r);
|
||||
}, $line);
|
||||
} else {
|
||||
if (strpos($line, 'jisx0208_2charset') !== false) {
|
||||
echo $line;
|
||||
$in = true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue