home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / cku208.tar / ckcuni.h < prev    next >
C/C++ Source or Header  |  2002-01-21  |  11KB  |  267 lines

  1. /*  C K C U N I . H  --  Unicode/Terminal character-set translations  */
  2.  
  3. /*
  4.   Copyright (C) 1999, 2002,
  5.     Trustees of Columbia University in the City of New York.
  6.     All rights reserved.  See the C-Kermit COPYING.TXT file or the
  7.     copyright text in the ckcmai.c module for disclaimer and permissions.
  8.  
  9.   Authors:
  10.     Frank da Cruz <fdc@columbia.edu>
  11.     Jeffrey Altman <jaltman@columbia.edu>
  12.     The Kermit Project, Columbia University, New York City.
  13. */
  14.  
  15. /* Terminal character sets */
  16.  
  17. #ifndef CKOUNI_H
  18. #define CKOUNI_H
  19. #ifdef OS2
  20. #ifndef CKOUNI
  21. #define CKOUNI                          /* Use UNICODE for OS/2 functions */
  22. #endif /* CKOUNI */
  23. #ifdef KUI
  24. #define X_CKOUNI_IN                     /* Use Unicode Input */
  25. #define CKOUNI_OUT
  26. #endif /* KUI */
  27. #endif /* OS2 */
  28.  
  29. /* Terminal Character Sets */
  30.  
  31. #define TX_ASCII        0               /* US ASCII */
  32. #define TX_BRITISH      1               /* British ISO 646 */
  33. #define TX_CN_FRENCH    2               /* Canadian French NRC */
  34. #define TX_CUBAN        3               /* Cuba */
  35. #define TX_CZECH        4               /* Czech Republic */
  36. #define TX_DANISH       5               /* Denmark / Norway ISO 646 */
  37. #define TX_DUTCH        6               /* Dutch NRC */
  38. #define TX_FINNISH      7               /* Finnish NRC */
  39. #define TX_FRENCH       8               /* French ISO 646 */
  40. #define TX_GERMAN       9               /* German ISO 646 */
  41. #define TX_HE7         10               /* Hebrew 7 (DEC) */
  42. #define TX_HUNGARIAN   11               /* Hungarian ISO 646 */
  43. #define TX_ICELANDIC   12               /* Icelandic NRC */
  44. #define TX_ITALIAN     13               /* Italian ISO 646 */
  45. #define TX_J201R       14               /* JIS 0201 Japanese Roman */
  46. #define TX_J201K       15               /* JIS 0201 Katakana */
  47. #define TX_KOI7        16               /* Short KOI */
  48. #define TX_NORWEGIAN   17               /* Denmark / Norway ISO 646 */
  49. #define TX_PORTUGUESE  18               /* Portuguese ISO 646 */
  50. #define TX_SPANISH     19               /* Spanish ISO 646 */
  51. #define TX_SWEDISH     20               /* Swedish ISO 646 */
  52. #define TX_SWE_2       21               /* Swedish for names ISO 646 */
  53. #define TX_SWISS       22               /* Swiss NRC */
  54. #define TX_8859_1      23               /* Latin-1 */
  55. #define TX_8859_2      24               /* Latin-2 */
  56. #define TX_8859_3      25               /* Latin-3 */
  57. #define TX_8859_4      26               /* Latin-4 */
  58. #define TX_8859_5      27               /* Latin/Cyrillic */
  59. #define TX_8859_6      28               /* Latin/Arabic */
  60. #define TX_8859_7      29               /* Latin/Greek */
  61. #define TX_8859_8      30               /* Latin/Hebrew */
  62. #define TX_8859_9      31               /* Latin-5 */
  63. #define TX_8859_10     32               /* Latin-6 */
  64.  
  65. #define TX_KOI8        33               /* GOST 19768-74 KOI-8 */
  66.  
  67. #define TX_JIS7        34               /* JIS-7 */
  68. #define TX_SHJIS       35               /* Shift JIS */
  69. #define TX_JEUC        36               /* Japanese EUC */
  70. #define TX_JDEC        37               /* Japanese DEC Kanji */
  71.  
  72. #define TX_DECMCS      38               /* DEC MCS */
  73. #define TX_NEXT        39               /* NeXT */
  74. #define TX_DGI         40               /* Data General International */
  75. #define TX_MACL1       41               /* Macintosh Latin-1 */
  76. #define TX_HPR8        42               /* HP Roman 8 */
  77.  
  78. /* Code pages */
  79.  
  80. #define TX_CP437       43               /* Original */
  81. #define TX_CP850       44               /* Multinational (Western Europe) */
  82. #define TX_CP852       45               /* Eastern Europe */
  83. #define TX_CP857       46               /* Turkey */
  84. #define TX_CP862       47               /* Hebrew */
  85. #define TX_CP864       48               /* Arabic */
  86. #define TX_CP866       49               /* Cyrillic */
  87. #define TX_CP869       50               /* Greek */
  88.  
  89. #define TX_DECSPEC     51               /* DEC Special Graphics */
  90. #define TX_DECTECH     52               /* DEC Technical */
  91. #define TX_C0PICT      53               /* C0 Display Controls */
  92. #define TX_C1PICT      54               /* C1 Display Controls */
  93. #define TX_IBMC0GRPH   55               /* IBM C0 Graphics (smileys) */
  94. #define TX_H19GRAPH    56               /* Heath/Zenith 19 Graphics */
  95. #define TX_TVIGRAPH    57               /* Televideo Graphics */
  96. #define TX_WYSE60G_N   58               /* Wyse 60 Native Mode Graphics */
  97. #define TX_WYSE60G_1   59               /* Wyse 60 Graphics 1 */
  98. #define TX_WYSE60G_2   60               /* Wyse 60 Graphics 2 */
  99. #define TX_WYSE60G_3   61               /* Wyse 60 Graphics 3 */
  100.  
  101. /* New ones that came too late for the nice grouping... */
  102.  
  103. #define TX_ELOT927     62               /* Greek ELOT 927 */
  104. #define TX_DGPCGRPH    63               /* DG PC Graphics */
  105. #define TX_DGLDGRPH    64               /* DG Line Drawing Graphics */
  106. #define TX_DGWPGRPH    65               /* DG Word Processing (etc) Graphics */
  107. #define TX_HPLINE      66               /* HP Line Drawing */
  108. #define TX_HPMATH      67               /* HP Math/Technical */
  109. #define TX_QNXGRPH     68               /* QNX Graphics */
  110.  
  111. /* Siemens Nixdorf character sets */
  112.  
  113. #define TX_SNIBRACK    69               /* SNI 97801 Brackets */
  114. #define TX_SNIEURO     70               /* SNI 97801 Euro  */
  115. #define TX_SNIFACET    71               /* SNI 97801 Facet */
  116. #define TX_SNIIBM      72               /* SNI 97801 "IBM" */
  117. #define TX_SNIBLANK    73               /* SNI 97801 Blanks */
  118.  
  119. /* Windows Code pages */
  120.  
  121. #define TX_CP1252      74               /* Latin-1 Windows */
  122. #define TX_CP1250      75               /* Latin-2 Windows */
  123. #define TX_CP1251      76               /* Cyrillic Windows */
  124. #define TX_CP1253      77               /* Greece Windows */
  125. #define TX_CP1254      78               /* Turkey Windows */
  126. #define TX_CP1257      79               /* Latin-4 Windows */
  127.  
  128. #define TX_CP856       80               /* Bulgaria CP856 (DATECS Ltd) */
  129. #define TX_CP855       81
  130. #define TX_CP819       82               /* Same as ISO 8859-1 */
  131. #define TX_CP912       83               /* Same as ISO 8859-2 */
  132. #define TX_CP913       84               /* Same as ISO 8859-3 */
  133. #define TX_CP914       85               /* Same as ISO 8859-4 */
  134. #define TX_CP915       86               /* Same as ISO 8859-5 */
  135. #define TX_CP1089      87               /* Same as ISO 8859-6 */
  136. #define TX_CP813       88               /* Same as ISO 8859-7 */
  137. #define TX_CP916       89               /* Same as ISO 8859-8 */
  138. #define TX_CP920       90               /* Same as ISO 8859-9 */
  139. #define TX_CP1051      91               /* Same as HP Roman 8 */
  140. #define TX_CP858       92               /* Multinational (W. Europe) w/Euro */
  141. #define TX_8859_15     93               /* Latin-9 */
  142. #define TX_CP923       94               /* Same as ISO 8859-15 */
  143.  
  144. #define TX_ELOT928     95               /* Same as ISO 8859-7 */
  145. #define TX_CP10000     96               /* Same as original Apple Quickdraw */
  146. #define TX_CP37        97               /* EBCDIC */
  147. #define TX_CP1255      98               /* Israel Windows */
  148. #define TX_CP1256      99               /* Arabic Windows */
  149. #define TX_CP1258     100               /* Viet Nam Windows */
  150. #define TX_MAZOVIA    101
  151. #define TX_TRANSP     102               /* Transparent - no translation */
  152. #define TX_HZ1500     103               /* Hazeltine 1500 graphics set */
  153. #define TX_KOI8R      104               /* KOI8R - Russian */
  154. #define TX_KOI8U      105               /* KOI8U - Ukrainian */
  155. #define TX_APL1       106               /* APL ISO IR 68 */
  156. #define TX_APL2       107               /* Dyadic Systems Inc APL */
  157. #define TX_APL3       108               /* APL-Plus (APL-2000) */
  158. #define TX_APL4       109               /* IBM APL/2 */
  159. #define TX_APL5       110               /* APL-2741 */
  160.  
  161. #define MAXTXSETS     111               /* Number of terminal character sets */
  162.  
  163. /* The following are not implemented yet */
  164. /* UTF-8 is supported as a special mode in Kermit 95 (see utf8 flag) */
  165.  
  166. #define TX_UTF7       128
  167. #define TX_UTF8       129
  168.  
  169. #define TX_HEXBYTES   242               /* Hex bytes */
  170. #define TX_DEBUG      243               /* Debugging but not hex bytes */
  171.  
  172. /* These are actually used */
  173.  
  174. #define TX_UNDEF      255               /* Unknown character-set */
  175.  
  176. /* Flag bit values */
  177.  
  178. #define X2U_STD   1                     /* Has standard ISO 4873 layout */
  179. #define X2U_ISO   2                     /* ISO standard character set */
  180. #define X2U_JIS   4                     /* Japan Industrial Standard */
  181. #define X2U_CP    8                     /* PC Code Page */
  182. #define X2U_DEC  16                     /* DEC Private character set */
  183. #define X2U_CXG  32                     /* Control codes used for graphics */
  184.  
  185. struct x_to_unicode {
  186.     int size;                           /* 94, 96, 128, or other */
  187.     int offset;                         /* 0, 32, 33, 128, 160, ... */
  188.     int flags;
  189.     int family;                         /* Language family, writing system */
  190.     char * keywd;                       /* Keyword name */
  191.     char * name;                        /* Descriptive name */
  192.     int code;                           /* ISO reg number if Standard */
  193.                                         /* CP number if Code-page, etc. */
  194.     char * final;                       /* Esc seq final char(s) (ISO, DEC) */
  195.     unsigned short map[256];            /* Mapping table */
  196. };
  197.  
  198. extern struct keytab txrtab[];
  199. extern int ntxrtab;
  200.  
  201. #ifndef NULL
  202. #define NULL (char *)0
  203. #endif /* NULL */
  204.  
  205. #ifndef USHORT
  206. #define USHORT unsigned short
  207. #endif /* USHORT */
  208.  
  209. #ifndef ULONG
  210. #define ULONG unsigned long
  211. #endif /* ULONG */
  212.  
  213. #ifndef CHAR
  214. #define CHAR unsigned char
  215. #endif /* CHAR */
  216.  
  217. #ifdef CK_ANSIC
  218. extern USHORT (*xl_u[MAXTXSETS+1])(CHAR); /* Blah-to-Unicode functions */
  219. extern int (*xl_tx[MAXTXSETS+1])(USHORT); /* Unicode-to-Blah functions */
  220. #else
  221. extern USHORT (*xl_u[MAXTXSETS+1])();
  222. extern int (*xl_tx[MAXTXSETS+1])();
  223. #endif /* CK_ANSIC */
  224. extern struct x_to_unicode * txrinfo[MAXTXSETS+1];
  225.  
  226. _PROTOTYP(int isunicode, (void));
  227. _PROTOTYP(int utf8_to_ucs2, (CHAR, USHORT **));
  228. _PROTOTYP(int ucs2_to_utf8, (USHORT, CHAR **));
  229. _PROTOTYP(int tx_cpsub, (USHORT));
  230. _PROTOTYP(int u_to_b, (CHAR) );
  231. _PROTOTYP(int u_to_b2, (void) );
  232. _PROTOTYP(int b_to_u, (CHAR, CHAR *, int, int) );
  233.  
  234. #ifdef KANJI
  235. _PROTOTYP(USHORT sj_to_un, (USHORT) );  /* Shift-JIS to Unicode */
  236. _PROTOTYP(USHORT un_to_sj, (USHORT) );  /* Unicode to Shift-JIS */
  237. #endif /* KANJI */
  238.  
  239. #ifdef OS2
  240. #ifdef NT
  241. _inline
  242. #else
  243. _Inline
  244. #endif /* NT */
  245. int
  246. isunicode(
  247. #ifdef CK_ANSIC
  248.           void
  249. #endif /* CK_ANSIC */
  250.           ) {
  251.     extern int tt_unicode;
  252. #ifdef NT
  253. #ifdef KUI
  254.     return(tt_unicode);
  255. #else /* KUI */
  256.     if (tt_unicode && !isWin95())
  257.       return(1);
  258.     else
  259.       return(0);
  260. #endif /* KUI */
  261. #else /* NT */
  262.     return(0);
  263. #endif /* NT */
  264. }
  265. #endif /* OS2 */
  266. #endif /* CKOUNI_H */
  267.