doc: 1-byte varlena headers can be used for user PLAIN storage
[pgsql.git] / src / backend / utils / mb / win1251.c
blob75129e6eff895f483951e66526fd8324a8666d5e
1 /*
2 * make KOI8->CP1251(win-1251) and CP1251(win-1251)->KOI8 translation table
3 * from koi-win.tab.
5 * Tatsuo Ishii
7 * src/backend/utils/mb/win1251.c
8 */
10 #include <stdio.h>
13 main()
15 int i;
16 char koitab[128],
17 wintab[128];
18 char buf[4096];
19 int koi,
20 win;
22 for (i = 0; i < 128; i++)
23 koitab[i] = wintab[i] = 0;
25 while (fgets(buf, sizeof(buf), stdin) != NULL)
27 if (*buf == '#')
28 continue;
29 sscanf(buf, "%d %d", &koi, &win);
30 if (koi < 128 || koi > 255 || win < 128 || win > 255)
32 fprintf(stderr, "invalid value %d\n", koi);
33 exit(1);
35 koitab[koi - 128] = win;
36 wintab[win - 128] = koi;
39 i = 0;
40 printf("static char koi2win[] = {\n");
41 while (i < 128)
43 int j = 0;
45 while (j < 8)
47 printf("0x%02x", koitab[i++]);
48 j++;
49 if (i >= 128)
50 break;
51 printf(", ");
53 printf("\n");
55 printf("};\n");
57 i = 0;
58 printf("static char win2koi[] = {\n");
59 while (i < 128)
61 int j = 0;
63 while (j < 8)
65 printf("0x%02x", wintab[i++]);
66 j++;
67 if (i >= 128)
68 break;
69 printf(", ");
71 printf("\n");
73 printf("};\n");