ckcuni.h 11 KB

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