diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2013-08-06 12:39:49 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2013-08-06 12:39:49 +0000 |
commit | be2f62b1c99597ad47dde539964c3a4a3b5cf773 (patch) | |
tree | a18554b899589412522eea3340658b8bcca05a89 /Build/source/texk/dvipdf-x/unicode.c | |
parent | f231a5d58023c8f1319480643976f01b3b8797d3 (diff) |
Recover texk/dvipdfm-x@31034 (essentially dvipdfmx and xdvipdfmx from branch-2013)
as texk/dvipdf-x.
Not built by default, only used to analyze various problems
git-svn-id: svn://tug.org/texlive/trunk@31364 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipdf-x/unicode.c')
-rw-r--r-- | Build/source/texk/dvipdf-x/unicode.c | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/Build/source/texk/dvipdf-x/unicode.c b/Build/source/texk/dvipdf-x/unicode.c new file mode 100644 index 00000000000..ddf7380b53a --- /dev/null +++ b/Build/source/texk/dvipdf-x/unicode.c @@ -0,0 +1,113 @@ +/* + + This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. + + Copyright (C) 2002-2012 by Jin-Hwan Cho and Shunsaku Hirata, + the dvipdfmx project team. + + Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +*/ + +/* + * Unicode related: + * Conversion between UTF-* and UCS-*. + * ToUnicode CMap + * + * Normalization? + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <string.h> + +#include "system.h" +#include "mem.h" +#include "error.h" +#include "dpxutil.h" + +#include "pdfobj.h" +#include "pdfresource.h" + +#include "pdfencoding.h" +#include "agl.h" +#include "unicode.h" + +static int __verbose = 0; + +#define UC_DEBUG 3 +#define UC_DEBUG_STR "UC" + +void +UC_set_verbose (void) +{ + __verbose++; +} + +#define UC_REPLACEMENT_CHAR 0x0000FFFDL + +#define UC_SUR_SHIFT 10 +#define UC_SUR_MASK 0x3FFUL +#define UC_SUR_LOW_START 0xDC00UL +#define UC_SUR_HIGH_START 0xD800UL + +int +UC_sput_UTF16BE (long ucv, unsigned char **pp, unsigned char *limptr) +{ + int count = 0; + unsigned char *p = *pp; + + if (ucv >= 0 && ucv <= 0xFFFF) { + if (p + 2 >= limptr) + ERROR("Not enough space available..."); + p[0] = (ucv >> 8) & 0xff; + p[1] = ucv & 0xff; + count = 2; + } else if (ucv >= 0x010000L && ucv <= 0x10FFFFL) { + unsigned short high, low; + + if (p + 4 >= limptr) + ERROR("Not enough space available..."); + ucv -= 0x00010000L; + high = (ucv >> UC_SUR_SHIFT) + UC_SUR_HIGH_START; + low = (ucv & UC_SUR_MASK) + UC_SUR_LOW_START; + p[0] = (high >> 8) & 0xff; + p[1] = (high & 0xff); + p[2] = (low >> 8) & 0xff; + p[3] = (low & 0xff); + count = 4; + } else { + if (p + 2 >= limptr) + ERROR("Not enough space available..."); + p[0] = (UC_REPLACEMENT_CHAR >> 8) & 0xff; + p[1] = (UC_REPLACEMENT_CHAR & 0xff); + count = 2; + } + + *pp += count; + return count; +} + +int +UC_is_valid (long ucv) +{ + if (ucv < 0 || (ucv >= 0x0000D800L && ucv <= 0x0000DFFFL)) + return 0; + return 1; +} + |