diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-08-23 10:17:01 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-08-23 10:17:01 +0000 |
commit | 82e002633513b0b73099d293aba30fb14360fa9a (patch) | |
tree | 06d3e4ce4cde2988646b6967ca11598d22278cbe /Build/source/texk/ptexenc | |
parent | 16c57cd409df0f406fc2710bcadadbd790cab70b (diff) |
more upTeX and e-upTeX
git-svn-id: svn://tug.org/texlive/trunk@23652 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/ptexenc')
-rw-r--r-- | Build/source/texk/ptexenc/ChangeLog | 14 | ||||
-rw-r--r-- | Build/source/texk/ptexenc/c-auto.in | 3 | ||||
-rwxr-xr-x | Build/source/texk/ptexenc/configure | 33 | ||||
-rw-r--r-- | Build/source/texk/ptexenc/configure.ac | 17 | ||||
-rw-r--r-- | Build/source/texk/ptexenc/ptexenc.c | 145 | ||||
-rw-r--r-- | Build/source/texk/ptexenc/ptexenc/kanjicnv.h | 14 | ||||
-rw-r--r-- | Build/source/texk/ptexenc/ptexenc/ptexenc.h | 22 | ||||
-rw-r--r-- | Build/source/texk/ptexenc/ptexenc/unicode.h | 7 | ||||
-rw-r--r-- | Build/source/texk/ptexenc/unicode.c | 23 |
9 files changed, 175 insertions, 103 deletions
diff --git a/Build/source/texk/ptexenc/ChangeLog b/Build/source/texk/ptexenc/ChangeLog index bc2329487f3..292921c2fc7 100644 --- a/Build/source/texk/ptexenc/ChangeLog +++ b/Build/source/texk/ptexenc/ChangeLog @@ -1,3 +1,17 @@ +2011-08-22 Peter Breitenlohner <peb@mppmu.mpg.de> + + More support for upTeX and e-upTeX. + * ptexenc.c, ptexenc/ptexenc.h: Add is_internalEUC(), + is_internalUPTEX(), ismultichr(), and ismultichr(). + + * ptexenc/unicode.h, unicode.c: Add UCStoUPTEX(), UPTEXtoUCS(). + + * ptexenc/kanjicnv.h, ptexenc/ptexenc.h, ptexenc/unicode.h: + Use prototypes as in ptexenc/ from W32TeX. + + * ptexenc.c: Handle default encoding with/without uptex. + * configure.ac: Remove option '--with-ptexenc-enc' configure. + 2011-08-18 Peter Breitenlohner <peb@mppmu.mpg.de> * version.ac: Update version number 1.2.0 => 1.3.0dev. diff --git a/Build/source/texk/ptexenc/c-auto.in b/Build/source/texk/ptexenc/c-auto.in index 02381398008..3038dc32b22 100644 --- a/Build/source/texk/ptexenc/c-auto.in +++ b/Build/source/texk/ptexenc/c-auto.in @@ -11,9 +11,6 @@ /* Define to 1 if the `closedir' function returns void instead of `int'. */ #undef CLOSEDIR_VOID -/* Default kanji encoding. */ -#undef DEFAULT_KANJI_ENC - /* Define to 1 if you have the <assert.h> header file. */ #undef HAVE_ASSERT_H diff --git a/Build/source/texk/ptexenc/configure b/Build/source/texk/ptexenc/configure index c58d72e9a07..86808049f1f 100755 --- a/Build/source/texk/ptexenc/configure +++ b/Build/source/texk/ptexenc/configure @@ -751,7 +751,6 @@ enable_compiler_warnings with_system_kpathsea with_kpathsea_includes with_kpathsea_libdir -with_ptexenc_enc enable_kanji_iconv ' ac_precious_vars='build_alias @@ -1411,8 +1410,6 @@ Optional Packages: kpathsea headers installed in DIR --with-kpathsea-libdir=DIR kpathsea library installed in DIR - --with-ptexenc-enc=ENC Default pTeX character encoding - (ENC=JIS/EUC/SJIS/UTF8, default UTF8) Some influential environment variables: CC C compiler command @@ -13998,36 +13995,6 @@ if test "x$kpse_cv_kpse_debug" != xyes; then : fi - -# Check whether --with-ptexenc-enc was given. -if test "${with_ptexenc_enc+set}" = set; then : - withval=$with_ptexenc_enc; -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking default pTeX character encoding" >&5 -$as_echo_n "checking default pTeX character encoding... " >&6; } -case $with_ptexenc_enc in #( - jis|JIS) : - DEFAULT_KANJI_ENC=ENC_JIS ;; #( - euc|EUC) : - DEFAULT_KANJI_ENC=ENC_EUC ;; #( - sjis|SJIS) : - DEFAULT_KANJI_ENC=ENC_SJIS ;; #( - ''|utf8|UTF8) : - DEFAULT_KANJI_ENC=ENC_UTF8 ;; #( - *) : - DEFAULT_KANJI_ENC=ENC_UTF8 - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unknown character encoding \`$with_ptexenc_enc'" >&5 -$as_echo "$as_me: WARNING: Unknown character encoding \`$with_ptexenc_enc'" >&2;} ;; -esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $DEFAULT_KANJI_ENC" >&5 -$as_echo "$DEFAULT_KANJI_ENC" >&6; } - -cat >>confdefs.h <<_ACEOF -#define DEFAULT_KANJI_ENC $DEFAULT_KANJI_ENC -_ACEOF - - # Check whether --enable-kanji-iconv was given. if test "${enable_kanji_iconv+set}" = set; then : enableval=$enable_kanji_iconv; diff --git a/Build/source/texk/ptexenc/configure.ac b/Build/source/texk/ptexenc/configure.ac index 5f5065f824e..feef29b29c1 100644 --- a/Build/source/texk/ptexenc/configure.ac +++ b/Build/source/texk/ptexenc/configure.ac @@ -22,23 +22,6 @@ KPSE_COMMON([ptexenc]) KPSE_KPATHSEA_FLAGS -dnl Default pTeX character encoding. -AC_ARG_WITH([ptexenc-enc], - AS_HELP_STRING([--with-ptexenc-enc=ENC], - [Default pTeX character encoding - (ENC=JIS/EUC/SJIS/UTF8, default UTF8)])) -AC_MSG_CHECKING([default pTeX character encoding]) -AS_CASE([$with_ptexenc_enc], - [jis|JIS], [DEFAULT_KANJI_ENC=ENC_JIS], - [euc|EUC], [DEFAULT_KANJI_ENC=ENC_EUC], - [sjis|SJIS], [DEFAULT_KANJI_ENC=ENC_SJIS], - [''|utf8|UTF8], [DEFAULT_KANJI_ENC=ENC_UTF8], - [DEFAULT_KANJI_ENC=ENC_UTF8 - AC_MSG_WARN([Unknown character encoding \`$with_ptexenc_enc'])]) -AC_MSG_RESULT([$DEFAULT_KANJI_ENC]) -AC_DEFINE_UNQUOTED([DEFAULT_KANJI_ENC], [$DEFAULT_KANJI_ENC], - [Default kanji encoding.]) - dnl Using iconv for kanji <=> unicode conversion AC_ARG_ENABLE([kanji-iconv], AS_HELP_STRING([--enable-kanji-iconv], diff --git a/Build/source/texk/ptexenc/ptexenc.c b/Build/source/texk/ptexenc/ptexenc.c index c58863ff498..386c36cb477 100644 --- a/Build/source/texk/ptexenc/ptexenc.c +++ b/Build/source/texk/ptexenc/ptexenc.c @@ -21,6 +21,10 @@ #define ENC_EUC 2 #define ENC_SJIS 3 #define ENC_UTF8 4 +#define ENC_UPTEX 5 + +static int default_kanji_enc = ENC_UTF8; +static boolean UPTEX_enabled; #define ESC '\033' @@ -43,7 +47,6 @@ static int file_enc = ENC_UNKNOWN; static int internal_enc = ENC_UNKNOWN; static int terminal_enc = ENC_UNKNOWN; - static const_string enc_to_string(int enc) { switch (enc) { @@ -51,6 +54,7 @@ static const_string enc_to_string(int enc) case ENC_EUC: return "euc"; case ENC_SJIS: return "sjis"; case ENC_UTF8: return "utf8"; + case ENC_UPTEX: if (UPTEX_enabled) return "uptex"; default: return "?"; } } @@ -58,11 +62,18 @@ static const_string enc_to_string(int enc) static int string_to_enc(const_string str) { if (str == NULL) return ENC_UNKNOWN; - if (strcasecmp(str, "default")== 0) return DEFAULT_KANJI_ENC; + if (strcasecmp(str, "default")== 0) return default_kanji_enc; if (strcasecmp(str, "jis") == 0) return ENC_JIS; if (strcasecmp(str, "euc") == 0) return ENC_EUC; if (strcasecmp(str, "sjis") == 0) return ENC_SJIS; if (strcasecmp(str, "utf8") == 0) return ENC_UTF8; + if (UPTEX_enabled && strcasecmp(str, "uptex") == 0) return ENC_UPTEX; + + if (strcasecmp(str, "BINARY") == 0) return ENC_JIS; + if (strcasecmp(str, "ISO-2022-JP") == 0) return ENC_JIS; + if (strcasecmp(str, "EUC-JP") == 0) return ENC_EUC; + if (strcasecmp(str, "Shift_JIS") == 0) return ENC_SJIS; + if (strcasecmp(str, "UTF-8") == 0) return ENC_UTF8; return -1; /* error */ } @@ -79,17 +90,19 @@ static int get_default_enc(void) } else if (enc != ENC_UNKNOWN) { return enc; } - return DEFAULT_KANJI_ENC; + return default_kanji_enc; } static void set_file_enc(int enc) { - file_enc = enc; + if (enc == ENC_UPTEX) file_enc = ENC_UTF8; + else /* rest */ file_enc = enc; } static void set_internal_enc(int enc) { if (enc == ENC_SJIS) internal_enc = ENC_SJIS; + else if (UPTEX_enabled && enc == ENC_UPTEX) internal_enc = ENC_UPTEX; else /* EUC, JIS, UTF8 */ internal_enc = ENC_EUC; } @@ -133,7 +146,14 @@ static int get_terminal_enc(void) /* enable/disable UPTEX */ void enable_UPTEX (boolean enable) { - (void) enable; + UPTEX_enabled = enable; + if (enable) + default_kanji_enc = ENC_UPTEX; + else { + default_kanji_enc = ENC_UTF8; + if (internal_enc == ENC_UPTEX) + internal_enc = ENC_EUC; + } } const_string get_enc_string(void) @@ -172,10 +192,43 @@ boolean is_internalSJIS(void) return (internal_enc == ENC_SJIS); } +boolean is_internalEUC(void) +{ + return (internal_enc == ENC_EUC); +} + +boolean is_internalUPTEX(void) +{ + return (internal_enc == ENC_UPTEX); +} + + +/* check char range */ +boolean ismultichr (int length, int nth, int c) +{ + if (is_internalUPTEX()) return isUTF8(length, nth, c); + if (length == 2) { + if (nth == 1) { + if (is_internalSJIS()) return isSJISkanji1(c); + /* EUC */ return isEUCkanji1(c); + } else if (nth == 2) { + if (is_internalSJIS()) return isSJISkanji2(c); + /* EUC */ return isEUCkanji2(c); + } + } + if ((length == 3 || length == 4) && + (0 < nth && nth <= length)) return false; + fprintf(stderr, "ismultichr: unexpected param length=%d, nth=%d\n", + length, nth); + return false; +} /* check char range (kanji 1st) */ boolean iskanji1(int c) { + if (is_internalUPTEX()) return (isUTF8(2,1,c) || + isUTF8(3,1,c) || + isUTF8(4,1,c)); if (is_internalSJIS()) return isSJISkanji1(c); /* EUC */ return isEUCkanji1(c); } @@ -188,9 +241,14 @@ boolean iskanji2(int c) } /* multi-byte char length in s[pos] */ -int multistrlen(string s, int len, int pos) +int multistrlen(unsigned char *s, int len, int pos) { s += pos; len -= pos; + if (is_internalUPTEX()) { + int ret = UTF8Slength(s, len); + if (ret < 0) return 1; + return ret; + } if (len < 2) return 1; if (is_internalSJIS()) { if (isSJISkanji1(s[0]) && isSJISkanji2(s[1])) return 2; @@ -200,10 +258,27 @@ int multistrlen(string s, int len, int pos) return 1; } -/* buffer (EUC/SJIS/UTF-8) to internal (EUC/SJIS) code conversion */ -long fromBUFF(string s, int len, int pos) +/* with not so strict range check */ +int multibytelen (int first_byte) +{ + if (is_internalUPTEX()) { + return UTF8length(first_byte); + } else if (is_internalSJIS()) { + if (isSJISkanji1(first_byte)) return 2; + } else { /* EUC */ + if (isEUCkanji1(first_byte)) return 2; + } + return 1; +} + +/* buffer (EUC/SJIS/UTF-8) to internal (EUC/SJIS/UPTEX) code conversion */ +long fromBUFF(unsigned char *s, int len, int pos) { s += pos; len -= pos; + if (is_internalUPTEX()) { + if (UTF8Slength(s, len) < 0) return s[0]; + return UCStoUPTEX(UTF8StoUCS(s)); + } if (len < 2) return s[0]; if (is_internalSJIS()) { if (isSJISkanji1(s[0]) && isSJISkanji2(s[1])) return HILO(s[0], s[1]); @@ -213,85 +288,95 @@ long fromBUFF(string s, int len, int pos) return s[0]; } -/* internal (EUC/SJIS) to buffer (EUC/SJIS) code conversion */ +/* internal (EUC/SJIS/UPTEX) to buffer (EUC/SJIS/UTF-8) code conversion */ long toBUFF(long kcode) { + if (is_internalUPTEX()) kcode = UCStoUTF8(UPTEXtoUCS(kcode)); return kcode; } -/* JIS to internal (EUC/SJIS) code conversion */ +/* JIS to internal (EUC/SJIS/UPTEX) code conversion */ long fromJIS(long kcode) { + if (is_internalUPTEX()) return UCStoUPTEX(JIStoUCS2(kcode)); if (is_internalSJIS()) return JIStoSJIS(kcode); /* EUC */ return JIStoEUC(kcode); } -/* internal (EUC/SJIS) to JIS code conversion */ +/* internal (EUC/SJIS/UPTEX) to JIS code conversion */ long toJIS(long kcode) { + if (is_internalUPTEX()) return UCS2toJIS(UPTEXtoUCS(kcode)); if (is_internalSJIS()) return SJIStoJIS(kcode); /* EUC */ return EUCtoJIS(kcode); } -/* EUC to internal (EUC/SJIS) code conversion */ +/* EUC to internal (EUC/SJIS/UPTEX) code conversion */ long fromEUC(long kcode) { - if (is_internalSJIS()) return fromJIS(EUCtoJIS(kcode)); - /* EUC */ return kcode; + if (!is_internalUPTEX() && !is_internalSJIS()) return kcode; + return fromJIS(EUCtoJIS(kcode)); } -/* internal (EUC/SJIS) to EUC code conversion */ +/* internal (EUC/SJIS/UPTEX) to EUC code conversion */ static long toEUC(long kcode) { - if (is_internalSJIS()) return JIStoEUC(toJIS(kcode)); - /* EUC */ return kcode; - + if (!is_internalUPTEX() && !is_internalSJIS()) return kcode; + return JIStoEUC(toJIS(kcode)); } -/* SJIS to internal (EUC/SJIS) code conversion */ +/* SJIS to internal (EUC/SJIS/UPTEX) code conversion */ long fromSJIS(long kcode) { if (is_internalSJIS()) return kcode; - /* EUC */ return fromJIS(SJIStoJIS(kcode)); + return fromJIS(SJIStoJIS(kcode)); } -/* internal (EUC/SJIS) to SJIS code conversion */ +/* internal (EUC/SJIS/UPTEX) to SJIS code conversion */ static long toSJIS(long kcode) { if (is_internalSJIS()) return kcode; - /* EUC */ return JIStoSJIS(toJIS(kcode)); + return JIStoSJIS(toJIS(kcode)); } -/* KUTEN to internal (EUC/SJIS) code conversion */ +/* KUTEN to internal (EUC/SJIS/UPTEX) code conversion */ long fromKUTEN(long kcode) { return fromJIS(KUTENtoJIS(kcode)); } -/* UCS to internal (EUC/SJIS) code conversion */ +/* UCS to internal (EUC/SJIS/UPTEX) code conversion */ long fromUCS(long kcode) { + if (is_internalUPTEX()) return UCStoUPTEX(kcode); kcode = UCS2toJIS(kcode); if (kcode == 0) return 0; return fromJIS(kcode); } -/* internal (EUC/SJIS) to UCS code conversion */ +/* internal (EUC/SJIS/UPTEX) to UCS code conversion */ long toUCS(long kcode) { + if (is_internalUPTEX()) return UPTEXtoUCS(kcode); return JIStoUCS2(toJIS(kcode)); } -/* internal (EUC/SJIS) to 'enc' code conversion */ +/* internal (EUC/SJIS/UPTEX) to UTF-8 code conversion */ +static long toUTF8 (long kcode) +{ + return UCStoUTF8(toUCS(kcode)); +} + +/* internal (EUC/SJIS/UPTEX) to 'enc' code conversion */ static long toENC(long kcode, int enc) { switch (enc) { - case ENC_UTF8: return UCStoUTF8(toUCS(kcode)); + case ENC_UTF8: return toUTF8(kcode); case ENC_JIS: return toJIS(kcode); case ENC_EUC: return toEUC(kcode); case ENC_SJIS: return toSJIS(kcode); @@ -379,7 +464,7 @@ static int ungetc4(int c, FILE *fp) } -static string buffer; +static unsigned char *buffer; static long first, last; static boolean combin_voiced_sound(boolean semi) { @@ -521,8 +606,8 @@ static int infile_enc[NOFILE]; /* ENC_UNKNOWN (=0): not determined other: determined */ /* input line with encoding conversion */ -long input_line2(FILE *fp, string buff, long pos, - const long buffsize, int *lastchar) +long input_line2(FILE *fp, unsigned char *buff, long pos, + const long buffsize, int *lastchar) { long i; static boolean injis = false; diff --git a/Build/source/texk/ptexenc/ptexenc/kanjicnv.h b/Build/source/texk/ptexenc/ptexenc/kanjicnv.h index 7eb71355f0e..3ca732d5159 100644 --- a/Build/source/texk/ptexenc/ptexenc/kanjicnv.h +++ b/Build/source/texk/ptexenc/ptexenc/kanjicnv.h @@ -18,18 +18,18 @@ extern boolean isSJISkanji1(int c); extern boolean isSJISkanji2(int c); /* EUC <=> JIS X 0208 code conversion */ -extern int EUCtoJIS(int); -extern int JIStoEUC(int); +extern int EUCtoJIS(int c); +extern int JIStoEUC(int c); /* Shift JIS <=> JIS Kanji code conversion */ -extern int SJIStoJIS(int); -extern int JIStoSJIS(int); +extern int SJIStoJIS(int c); +extern int JIStoSJIS(int c); /* Shift JIS <=> EUC Kanji code conversion */ -extern int SJIStoEUC(int); -extern int EUCtoSJIS(int); +extern int SJIStoEUC(int c); +extern int EUCtoSJIS(int c); /* KUTEN => JIS kanji code conversion */ -extern int KUTENtoJIS(int); +extern int KUTENtoJIS(int c); #endif /* PTEXENC_KANJICNV_H */ diff --git a/Build/source/texk/ptexenc/ptexenc/ptexenc.h b/Build/source/texk/ptexenc/ptexenc/ptexenc.h index 05955ea1279..2863f6e0574 100644 --- a/Build/source/texk/ptexenc/ptexenc/ptexenc.h +++ b/Build/source/texk/ptexenc/ptexenc/ptexenc.h @@ -34,28 +34,34 @@ extern PTENCDLL void enable_UPTEX (boolean enable); /* get/set Kanji encoding by string */ extern PTENCDLL const_string get_enc_string(void); -extern PTENCDLL int set_enc_string(const_string file, const_string inter); +extern PTENCDLL int set_enc_string(const_string file, const_string inter); #define getencstring get_enc_string #define setencstring set_enc_string -/* decide if internal Kanji encode is SJIS or not */ +/* decide if internal Kanji encode is SJIS/UPTEX or not */ extern PTENCDLL boolean is_internalSJIS(void); +extern PTENCDLL boolean is_internalEUC(void); +extern PTENCDLL boolean is_internalUPTEX(void); #define isinternalSJIS is_internalSJIS +#define isinternalEUC is_internalEUC +#define isinternalUPTEX is_internalUPTEX /* check char range */ +extern PTENCDLL boolean ismultichr (int length, int nth, int c); extern PTENCDLL boolean iskanji1(int c); extern PTENCDLL boolean iskanji2(int c); -/* internal (EUC/SJIS) from/to buffer (EUC/SJIS/UTF-8) code conversion */ -extern PTENCDLL int multistrlen(string s, int len, int pos); -extern PTENCDLL long fromBUFF(string s, int len, int pos); +/* internal (EUC/SJIS/UPTEX) from/to buffer (EUC/SJIS/UTF-8) code conversion */ +extern PTENCDLL int multistrlen(unsigned char *s, int len, int pos); +extern PTENCDLL int multibytelen (int first_byte); +extern PTENCDLL long fromBUFF(unsigned char *s, int len, int pos); extern PTENCDLL long toBUFF(long inter); -/* internal (EUC/SJIS) from/to DVI (JIS) code conversion */ +/* internal (EUC/SJIS/UPTEX) from/to DVI (JIS) code conversion */ #define fromDVI fromJIS #define toDVI toJIS -/* JIS/EUC/SJIS/KUTN/UCS to internal (EUC/SJIS) code conversion */ +/* JIS/EUC/SJIS/KUTN/UCS to internal (EUC/SJIS/UPTEX) code conversion */ /* (only for \euc primitive, etc.) */ extern PTENCDLL long toJIS(long kcode); extern PTENCDLL long fromJIS(long jis); @@ -70,7 +76,7 @@ extern PTENCDLL int putc2(int c, FILE *fp); extern PTENCDLL int fputs2(const char *s, FILE *fp); /* input line with encoding conversion */ -extern PTENCDLL long input_line2(FILE *fp, string buff, long pos, +extern PTENCDLL long input_line2(FILE *fp, unsigned char *buff, long pos, const long buffsize, int *lastchar); /* open/close through nkf */ diff --git a/Build/source/texk/ptexenc/ptexenc/unicode.h b/Build/source/texk/ptexenc/ptexenc/unicode.h index 45ceee9f9d5..13e1567a714 100644 --- a/Build/source/texk/ptexenc/ptexenc/unicode.h +++ b/Build/source/texk/ptexenc/ptexenc/unicode.h @@ -13,10 +13,13 @@ extern boolean isUTF8(int length, int nth, int c); extern int UTF8length(int first_byte); -extern int UTF8Slength(string buff, int buff_len); -extern long UTF8StoUCS(string s); +extern int UTF8Slength(unsigned char *buff, int buff_len); +extern long UTF8StoUCS(unsigned char *s); extern long PTENCDLL UCStoUTF8(long ucs); +extern long UCStoUPTEX(long ucs); +extern long UPTEXtoUCS(long uptex); + #define LONG(a,b,c,d) ( ((long)(a)<<24) | ((long)(b)<<16) | ((c)<<8) | (d) ) #define BYTE1(x) (((x)>>24) & 0xff) #define BYTE2(x) (((x)>>16) & 0xff) diff --git a/Build/source/texk/ptexenc/unicode.c b/Build/source/texk/ptexenc/unicode.c index 275ebd75d40..be8768964e3 100644 --- a/Build/source/texk/ptexenc/unicode.c +++ b/Build/source/texk/ptexenc/unicode.c @@ -43,7 +43,7 @@ int UTF8length(int first_byte) /* with strict range check */ -int UTF8Slength(string buff, int buff_len) +int UTF8Slength(unsigned char *buff, int buff_len) { int i, len; @@ -58,7 +58,7 @@ int UTF8Slength(string buff, int buff_len) /* WITHOUT strict range check */ -long UTF8StoUCS(string s) +long UTF8StoUCS(unsigned char *s) { switch (UTF8length(s[0])) { case 1: return s[0]; @@ -70,7 +70,7 @@ long UTF8StoUCS(string s) } #if 0 /* not used */ -int UCStoUTF8S(long ucs, string s) +int UCStoUTF8S(long ucs, unsigned char *s) { if (ucs < 0x80) { *s = ucs; @@ -112,3 +112,20 @@ long UCStoUTF8(long ucs) UCStoUTF8D4(ucs)); return 0; /* unsupported */ } + + +#define UCS_MAX 0x110000L + +/* using over U+10.FFFF Area */ +long UCStoUPTEX (long ucs) +{ + if (0x7F < ucs && ucs < 0x1000) ucs += UCS_MAX; + return ucs; +} + +/* using over U+10.FFFF Area */ +long UPTEXtoUCS (long uptex) +{ + if (UCS_MAX + 0x7F < uptex && uptex < UCS_MAX + 0x1000) uptex -= UCS_MAX; + return uptex; +} |