aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/mb/win.c
blob: 272c6a638c119c563c7dbc4af71392d5a0c1782d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * make KOI8->CP1251(win-1251) and CP1251(win-1251)->KOI8 translation table
 * from koi-win.tab.
 *
 * Tatsuo Ishii
 *
 * $Id: win.c,v 1.1 1999/03/24 07:01:37 ishii Exp $
 */

#include <stdio.h>
main()
{
  int i;
  char koitab[128],wintab[128];
  char buf[4096];
  int koi,win;

  for (i=0;i<128;i++) {
    koitab[i] = wintab[i] = 0;
  }

  while (fgets(buf,sizeof(buf),stdin) != NULL) {
    if (*buf == '#') {
      continue;
    }
    sscanf(buf,"%d %d",&koi,&win);
    if (koi < 128 || koi > 255 || win < 128 || win > 255) {
      fprintf(stderr,"invalid value %d\n",koi);
      exit(1);
    }
    koitab[koi-128] = win;
    wintab[win-128] = koi;
  }

  i = 0;
  printf("static char koi2win[] = {\n");
  while (i < 128) {
    int j = 0;
    while (j < 8) {
      printf("0x%02x",koitab[i++]);
      j++;
      if (i >= 128) {
	break;
      }
      printf(", ");
    }
    printf("\n");
  }
  printf("};\n");

  i = 0;
  printf("static char win2koi[] = {\n");
  while (i < 128) {
    int j = 0;
    while (j < 8) {
      printf("0x%02x",wintab[i++]);
      j++;
      if (i >= 128) {
	break;
      }
      printf(", ");
    }
    printf("\n");
  }
  printf("};\n");
}