tcs.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. #ifndef PLAN9
  2. #include <sys/types.h>
  3. #include <stdio.h>
  4. #include <unistd.h>
  5. #include <stdlib.h>
  6. #include <fcntl.h>
  7. #include <string.h>
  8. #include <errno.h>
  9. #include "plan9.h"
  10. #else /* PLAN9 */
  11. #include <u.h>
  12. #include <libc.h>
  13. #include <bio.h>
  14. #endif /* PLAN9 */
  15. #include "cyrillic.h"
  16. #include "misc.h"
  17. #include "ms.h"
  18. #include "8859.h"
  19. #include "big5.h"
  20. #include "gb.h"
  21. #include "hdr.h"
  22. #include "conv.h"
  23. void usage(void);
  24. void list(void);
  25. int squawk = 1;
  26. int clean = 0;
  27. int verbose = 0;
  28. long ninput, noutput, nrunes, nerrors;
  29. char *file = "stdin";
  30. char *argv0;
  31. Rune runes[N];
  32. char obuf[UTFmax*N]; /* maximum bloat from N runes */
  33. long tab[NRUNE];
  34. #ifndef PLAN9
  35. extern char version[];
  36. #endif
  37. void intable(int, long *, struct convert *);
  38. void unicode_in(int, long *, struct convert *);
  39. void unicode_out(Rune *, int, long *);
  40. int
  41. main(int argc, char **argv)
  42. {
  43. char *from = "utf";
  44. char *to = "utf";
  45. int fd;
  46. int listem = 0;
  47. struct convert *t, *f;
  48. ARGBEGIN {
  49. case 'c':
  50. clean = 1;
  51. break;
  52. case 'f':
  53. from = EARGF(usage());
  54. break;
  55. case 'l':
  56. listem = 1;
  57. break;
  58. case 's':
  59. squawk = 0;
  60. break;
  61. case 't':
  62. to = EARGF(usage());
  63. break;
  64. case 'v':
  65. verbose = 1;
  66. break;
  67. default:
  68. usage();
  69. break;
  70. } ARGEND
  71. USED(argc);
  72. if(verbose)
  73. squawk = 1;
  74. if(listem){
  75. list();
  76. EXIT(0, 0);
  77. }
  78. if(!from || !to)
  79. usage();
  80. f = conv(from, 1);
  81. t = conv(to, 0);
  82. #define PROC {if(f->flags&Table)\
  83. intable(fd, (long *)f->data, t);\
  84. else\
  85. ((Infn)(f->fn))(fd, (long *)0, t);}
  86. if(*argv){
  87. while(*argv){
  88. file = *argv;
  89. #ifndef PLAN9
  90. if((fd = open(*argv, 0)) < 0){
  91. EPR "%s: %s: %s\n", argv0, *argv, strerror(errno));
  92. #else /* PLAN9 */
  93. if((fd = open(*argv, OREAD)) < 0){
  94. EPR "%s: %s: %r\n", argv0, *argv);
  95. #endif /* PLAN9 */
  96. EXIT(1, "open failure");
  97. }
  98. PROC
  99. close(fd);
  100. argv++;
  101. }
  102. } else {
  103. fd = 0;
  104. PROC
  105. }
  106. if(verbose)
  107. EPR "%s: %ld input bytes, %ld runes, %ld output bytes (%ld errors)\n", argv0,
  108. ninput, nrunes, noutput, nerrors);
  109. EXIT(((nerrors && squawk)? 1:0), ((nerrors && squawk)? "conversion error":0));
  110. return(0); /* shut up compiler */
  111. }
  112. void
  113. usage(void)
  114. {
  115. EPR "Usage: %s [-slv] [-f cs] [-t cs] [file ...]\n", argv0);
  116. verbose = 1;
  117. list();
  118. EXIT(1, "usage");
  119. }
  120. void
  121. list(void)
  122. {
  123. struct convert *c;
  124. char ch = verbose?'\t':' ';
  125. #ifndef PLAN9
  126. EPR "%s version = '%s'\n", argv0, version);
  127. #endif
  128. if(verbose)
  129. EPR "character sets:\n");
  130. else
  131. EPR "cs:");
  132. for(c = convert; c->name; c++){
  133. if((c->flags&From) && c[1].name && (strcmp(c[1].name, c->name) == 0)){
  134. EPR "%c%s", ch, c->name);
  135. c++;
  136. } else if(c->flags&Table)
  137. EPR "%c%s", ch, c->name);
  138. else if(c->flags&From)
  139. EPR "%c%s(from)", ch, c->name);
  140. else
  141. EPR "%c%s(to)", ch, c->name);
  142. if(verbose)
  143. EPR "\t%s\n", c->chatter);
  144. }
  145. if(!verbose)
  146. EPR "\n");
  147. }
  148. struct convert *
  149. conv(char *name, int from)
  150. {
  151. struct convert *c;
  152. for(c = convert; c->name; c++){
  153. if(strcmp(c->name, name) != 0)
  154. continue;
  155. if(c->flags&Table)
  156. return(c);
  157. if(((c->flags&From) == 0) == (from == 0))
  158. return(c);
  159. }
  160. EPR "%s: charset `%s' unknown\n", argv0, name);
  161. EXIT(1, "unknown character set");
  162. return(0); /* just shut the compiler up */
  163. }
  164. void
  165. swab2(char *b, int n)
  166. {
  167. char *e, p;
  168. for(e = b+n; b < e; b++){
  169. p = *b;
  170. *b = b[1];
  171. *++b = p;
  172. }
  173. }
  174. void
  175. unicode_in(int fd, long *notused, struct convert *out)
  176. {
  177. Rune buf[N];
  178. int n;
  179. int swabme;
  180. USED(notused);
  181. if(read(fd, (char *)buf, 2) != 2)
  182. return;
  183. ninput += 2;
  184. switch(buf[0])
  185. {
  186. default:
  187. OUT(out, buf, 1);
  188. case 0xFEFF:
  189. swabme = 0;
  190. break;
  191. case 0xFFFE:
  192. swabme = 1;
  193. break;
  194. }
  195. while((n = read(fd, (char *)buf, 2*N)) > 0){
  196. ninput += n;
  197. if(n&1){
  198. if(squawk)
  199. EPR "%s: odd byte count in %s\n", argv0, file);
  200. nerrors++;
  201. if(clean)
  202. n--;
  203. else {
  204. n++;
  205. buf[n/2] = Runeerror;
  206. if(swabme) /* swab so later swab undoes it */
  207. swab2((char *)&buf[n/2], 2);
  208. }
  209. }
  210. if(swabme)
  211. swab2((char *)buf, n);
  212. OUT(out, buf, n/2);
  213. }
  214. }
  215. void
  216. unicode_out(Rune *base, int n, long *notused)
  217. {
  218. static int first = 1;
  219. USED(notused);
  220. nrunes += n;
  221. if(first){
  222. unsigned short x = 0xFEFF;
  223. noutput += 2;
  224. write(1, (char *)&x, 2);
  225. first = 0;
  226. }
  227. noutput += 2*n;
  228. write(1, (char *)base, 2*n);
  229. }
  230. void
  231. intable(int fd, long *table, struct convert *out)
  232. {
  233. uchar buf[N];
  234. uchar *p, *e;
  235. Rune *r;
  236. int n;
  237. long c;
  238. while((n = read(fd, (char *)buf, N)) > 0){
  239. ninput += n;
  240. r = runes;
  241. for(p = buf, e = buf+n; p < e; p++){
  242. c = table[*p];
  243. if(c < 0){
  244. if(squawk)
  245. EPR "%s: bad char 0x%x near byte %ld in %s\n", argv0, *p, ninput+(p-e), file);
  246. nerrors++;
  247. if(clean)
  248. continue;
  249. c = BADMAP;
  250. }
  251. *r++ = c;
  252. }
  253. OUT(out, runes, r-runes);
  254. }
  255. if(n < 0){
  256. #ifdef PLAN9
  257. EPR "%s: input read: %r\n", argv0);
  258. #else
  259. EPR "%s: input read: %s\n", argv0, strerror(errno));
  260. #endif
  261. EXIT(1, "input read error");
  262. }
  263. }
  264. void
  265. outtable(Rune *base, int n, long *map)
  266. {
  267. long c;
  268. char *p;
  269. int i;
  270. nrunes += n;
  271. for(i = 0; i < NRUNE; i++)
  272. tab[i] = -1;
  273. for(i = 0; i < 256; i++)
  274. if(map[i] >= 0)
  275. tab[map[i]] = i;
  276. for(i = 0, p = obuf; i < n; i++){
  277. c = tab[base[i]];
  278. if(c < 0){
  279. if(squawk)
  280. EPR "%s: rune 0x%x not in output cs\n", argv0, base[i]);
  281. nerrors++;
  282. if(clean)
  283. continue;
  284. c = BADMAP;
  285. }
  286. *p++ = c;
  287. }
  288. noutput += p-obuf;
  289. write(1, obuf, p-obuf);
  290. }
  291. long tabascii[256] =
  292. {
  293. 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
  294. 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
  295. 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
  296. 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
  297. 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
  298. 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
  299. 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
  300. 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
  301. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  302. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  303. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  304. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  305. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  306. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  307. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  308. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  309. };
  310. long tabmsdos[256] = /* from jhelling@cs.ruu.nl (Jeroen Hellingman) */
  311. {
  312. 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
  313. 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
  314. 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
  315. 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
  316. 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
  317. 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
  318. 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
  319. 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
  320. 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7, /* latin */
  321. 0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
  322. 0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
  323. 0x00ff, 0x00d6, 0x00dc, 0x00a2, 0x00a3, 0x00a5, 0x20a7, 0x0192,
  324. 0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
  325. 0x00bf, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
  326. 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, /* forms */
  327. 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
  328. 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
  329. 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
  330. 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
  331. 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
  332. 0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4, /* greek */
  333. 0x03a6, 0x0398, 0x2126, 0x03b4, 0x221e, 0x2205, 0x2208, 0x2229,
  334. 0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248, /* math */
  335. 0x00b0, 0x2022, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x220e, 0x00a0,
  336. };
  337. long tabmsdos2[256] = /* from jhelling@cs.ruu.nl (Jeroen Hellingman) */
  338. {
  339. 0x0000, 0x263a, 0x263b, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022,
  340. 0x25d8, 0x25cb, 0x25d9, 0x2642, 0x2640, 0x266a, 0x266b, 0x263c,
  341. 0x25b6, 0x25c0, 0x2195, 0x203c, 0x00b6, 0x00a7, 0x2043, 0x21a8,
  342. 0x2191, 0x2193, 0x2192, 0x2190, 0x2319, 0x2194, 0x25b2, 0x25bc,
  343. 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
  344. 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
  345. 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
  346. 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
  347. 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
  348. 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
  349. 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7, /* latin */
  350. 0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
  351. 0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
  352. 0x00ff, 0x00d6, 0x00dc, 0x00a2, 0x00a3, 0x00a5, 0x20a7, 0x0192,
  353. 0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
  354. 0x00bf, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
  355. 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, /* forms */
  356. 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
  357. 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
  358. 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
  359. 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
  360. 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
  361. 0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4, /* greek */
  362. 0x03a6, 0x0398, 0x2126, 0x03b4, 0x221e, 0x2205, 0x2208, 0x2229,
  363. 0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248, /* math */
  364. 0x00b0, 0x2022, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x220e, 0x00a0,
  365. };
  366. struct convert convert[] =
  367. { /* if two entries have the same name, put the from one first */
  368. { "8859-1", "Latin-1 (Western and Northern Europe including Italian)", Table, (void *)tab8859_1 },
  369. { "8859-2", "Latin-2 (Eastern Europe except Turkey and the Baltic countries)", Table, (void *)tab8859_2 },
  370. { "8859-3", "Latin-3 (Mediterranean, South Africa, Esperanto)", Table, (void *)tab8859_3 },
  371. { "8859-4", "Latin-4 (Scandinavia and the Baltic countries; obsolete)", Table, (void *)tab8859_4 },
  372. { "8859-5", "Part 5 (Cyrillic)", Table, (void *)tab8859_5 },
  373. { "8859-6", "Part 6 (Arabic)", Table, (void *)tab8859_6 },
  374. { "8859-7", "Part 7 (Greek)", Table, (void *)tab8859_7 },
  375. { "8859-8", "Part 8 (Hebrew)", Table, (void *)tab8859_8 },
  376. { "8859-9", "Latin-5 (Turkey, Western Europe except Icelandic and Faroese)", Table, (void *)tab8859_9 },
  377. { "8859-10", "Latin-6 (Northern Europe)", Table, (void *)tab8859_10 },
  378. { "8859-15", "Latin-9 (Western Europe)", Table, (void *)tab8859_15 },
  379. { "ascii", "7-bit ASCII", Table, (void *)tabascii },
  380. { "atari", "ATARI-ST character set", Table, (void *)tabatari },
  381. { "av", "Alternativnyj Variant", Table, (void *)tabav },
  382. { "big5", "Big 5 (HKU)", From|Func, 0, (Fnptr)big5_in },
  383. { "big5", "Big 5 (HKU)", Func, 0, (Fnptr)big5_out },
  384. { "cp437", "Code Page 437 (US)", Table, (void*)tabcp437 },
  385. { "cp720", "Code Page 720 (Arabic)", Table, (void*)tabcp720 },
  386. { "cp737", "Code Page 737 (Greek)", Table, (void*)tabcp737 },
  387. { "cp775", "Code Page 775 (Baltic)", Table, (void*)tabcp775 },
  388. { "cp850", "Code Page 850 (Multilingual Latin I)", Table, (void*)tabcp850 },
  389. { "cp852", "Code Page 852 (Latin II)", Table, (void*)tabcp852 },
  390. { "cp855", "Code Page 855 (Cyrillic)", Table, (void*)tabcp855 },
  391. { "cp857", "Code Page 857 (Turkish)", Table, (void*)tabcp857 },
  392. { "cp858", "Code Page 858 (Multilingual Latin I+Euro)", Table, (void*)tabcp858 },
  393. { "cp862", "Code Page 862 (Hebrew)", Table, (void*)tabcp862 },
  394. { "cp866", "Code Page 866 (Russian)", Table, (void*)tabcp866 },
  395. { "cp874", "Code Page 874 (Thai)", Table, (void*)tabcp874 },
  396. { "cp1250", "Code Page 1250 (Central Europe)", Table, (void *)tabcp1250 },
  397. { "cp1251", "Code Page 1251 (Cyrillic)", Table, (void *)tabcp1251 },
  398. { "cp1252", "Code Page 1252 (Latin I)", Table, (void *)tabcp1252 },
  399. { "cp1253", "Code Page 1253 (Greek)", Table, (void *)tabcp1253 },
  400. { "cp1254", "Code Page 1254 (Turkish)", Table, (void *)tabcp1254 },
  401. { "cp1255", "Code Page 1255 (Hebrew)", Table, (void *)tabcp1255 },
  402. { "cp1256", "Code Page 1256 (Arabic)", Table, (void *)tabcp1256 },
  403. { "cp1257", "Code Page 1257 (Baltic)", Table, (void *)tabcp1257 },
  404. { "cp1258", "Code Page 1258 (Vietnam)", Table, (void *)tabcp1258 },
  405. { "ebcdic", "EBCDIC", Table, (void *)tabebcdic }, /* 6f is recommended bad map */
  406. { "euc-k", "Korean EUC: ASCII+KS C 5601 1987", From|Func, 0, (Fnptr)uksc_in },
  407. { "euc-k", "Korean EUC: ASCII+KS C 5601 1987", Func, 0, (Fnptr)uksc_out },
  408. { "gb", "GB2312-80 (Chinese)", From|Func, 0, (Fnptr)gb_in },
  409. { "gb", "GB2312-80 (Chinese)", Func, 0, (Fnptr)gb_out },
  410. { "html", "HTML", From|Func, 0, (Fnptr)html_in },
  411. { "html", "HTML", Func, 0, (Fnptr)html_out },
  412. { "jis", "guesses at the JIS encoding", From|Func, 0, (Fnptr)jis_in },
  413. { "jis-kanji", "ISO 2022-JP (Japanese)", From|Func, 0, (Fnptr)jisjis_in },
  414. { "jis-kanji", "ISO 2022-JP (Japanese)", Func, 0, (Fnptr)jisjis_out },
  415. { "koi8", "KOI-8 (GOST 19769-74)", Table, (void *)tabkoi8 },
  416. { "latin1", "ISO 8859-1", Table, (void *)tab8859_1 },
  417. { "macrom", "Macintosh Standard Roman character set", Table, (void *)tabmacroman },
  418. { "microsoft", "Windows (CP 1252)", Table, (void *)tabcp1252 },
  419. { "msdos", "IBM PC (CP 437)", Table, (void *)tabcp437 },
  420. { "msdos2", "IBM PC (CP 437 with graphics in C0)", Table, (void *)tabmsdos2 },
  421. { "ms-kanji", "Microsoft, or Shift-JIS", From|Func, 0, (Fnptr)msjis_in },
  422. { "ms-kanji", "Microsoft, or Shift-JIS", Func, 0, (Fnptr)msjis_out },
  423. { "next", "NEXTSTEP character set", Table, (void *)tabnextstep },
  424. { "ov", "Osnovnoj Variant", Table, (void *)tabov },
  425. { "ps2", "IBM PS/2: (CP 850)", Table, (void *)tabcp850 },
  426. { "sf1", "ISO-646: Finnish/Swedish SF-1 variant", Table, (void *)tabsf1 },
  427. { "sf2", "ISO-646: Finnish/Swedish SF-2 variant (recommended)", Table, (void *)tabsf2 },
  428. { "tis", "Thai+ASCII (TIS 620-1986)", Table, (void *)tabtis620 },
  429. { "ucode", "Russian U-code", Table, (void *)tabucode },
  430. { "ujis", "EUC-JX: JIS 0208", From|Func, 0, (Fnptr)ujis_in },
  431. { "ujis", "EUC-JX: JIS 0208", Func, 0, (Fnptr)ujis_out },
  432. { "unicode", "Unicode 1.1", From|Func, 0, (Fnptr)unicode_in },
  433. { "unicode", "Unicode 1.1", Func, 0, (Fnptr)unicode_out },
  434. { "utf1", "UTF-1 (ISO 10646 Annex A)", From|Func, 0, (Fnptr)isoutf_in },
  435. { "utf1", "UTF-1 (ISO 10646 Annex A)", Func, 0, (Fnptr)isoutf_out },
  436. { "utf", "FSS-UTF a.k.a. UTF-8", From|Func, 0, (Fnptr)utf_in },
  437. { "utf", "FSS-UTF a.k.a. UTF-8", Func, 0, (Fnptr)utf_out },
  438. { "utf-l2", "from", From|Func, 0, (Fnptr)utf_in },
  439. { "utf-l2", "to", Func, 0, (Fnptr)utf_out },
  440. { "viet1", "Vietnamese VSCII-1 (1993)", Table, (void *)tabviet1 },
  441. { "viet2", "Vietnamese VSCII-2 (1993)", Table, (void *)tabviet2 },
  442. { "viscii", "Vietnamese VISCII 1.1 (1992)", Table, (void *)tabviscii },
  443. { 0 },
  444. };