aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>1999-03-24 07:01:37 +0000
committerTatsuo Ishii <ishii@postgresql.org>1999-03-24 07:01:37 +0000
commiteb42c1c762dbc11930ea3e9f05193823d766b7da (patch)
treefec2d9ed18776a2d276f9986b4ad7bb9725d5e1c
parente1a22d5e8442dbcf55b522f87f59334978c0619d (diff)
downloadpostgresql-eb42c1c762dbc11930ea3e9f05193823d766b7da.tar.gz
postgresql-eb42c1c762dbc11930ea3e9f05193823d766b7da.zip
These small utilities are for generating internal tables from
rcode encoding tables.
-rw-r--r--src/backend/utils/mb/alt.c66
-rw-r--r--src/backend/utils/mb/iso.c66
-rw-r--r--src/backend/utils/mb/win.c66
3 files changed, 198 insertions, 0 deletions
diff --git a/src/backend/utils/mb/alt.c b/src/backend/utils/mb/alt.c
new file mode 100644
index 00000000000..54f69cc594b
--- /dev/null
+++ b/src/backend/utils/mb/alt.c
@@ -0,0 +1,66 @@
+/*
+ * make KOI8->CP866(ALT) and CP866(ALT)->KOI8 translation table
+ * from koi-alt.tab.
+ *
+ * Tatsuo Ishii
+ *
+ * $Id: alt.c,v 1.1 1999/03/24 07:01:36 ishii Exp $
+ */
+
+#include <stdio.h>
+main()
+{
+ int i;
+ char koitab[128],alttab[128];
+ char buf[4096];
+ int koi,alt;
+
+ for (i=0;i<128;i++) {
+ koitab[i] = alttab[i] = 0;
+ }
+
+ while (fgets(buf,sizeof(buf),stdin) != NULL) {
+ if (*buf == '#') {
+ continue;
+ }
+ sscanf(buf,"%d %d",&koi,&alt);
+ if (koi < 128 || koi > 255 || alt < 128 || alt > 255) {
+ fprintf(stderr,"invalid value %d\n",koi);
+ exit(1);
+ }
+ koitab[koi-128] = alt;
+ alttab[alt-128] = koi;
+ }
+
+ i = 0;
+ printf("static char koi2alt[] = {\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 alt2koi[] = {\n");
+ while (i < 128) {
+ int j = 0;
+ while (j < 8) {
+ printf("0x%02x",alttab[i++]);
+ j++;
+ if (i >= 128) {
+ break;
+ }
+ printf(", ");
+ }
+ printf("\n");
+ }
+ printf("};\n");
+}
diff --git a/src/backend/utils/mb/iso.c b/src/backend/utils/mb/iso.c
new file mode 100644
index 00000000000..4141578a3b8
--- /dev/null
+++ b/src/backend/utils/mb/iso.c
@@ -0,0 +1,66 @@
+/*
+ * make KOI8->ISO8859-5 and ISO8859-5->KOI8 translation table
+ * from koi-iso.tab.
+ *
+ * Tatsuo Ishii
+ *
+ * $Id: iso.c,v 1.1 1999/03/24 07:01:37 ishii Exp $
+ */
+
+#include <stdio.h>
+main()
+{
+ int i;
+ char koitab[128],isotab[128];
+ char buf[4096];
+ int koi,iso;
+
+ for (i=0;i<128;i++) {
+ koitab[i] = isotab[i] = 0;
+ }
+
+ while (fgets(buf,sizeof(buf),stdin) != NULL) {
+ if (*buf == '#') {
+ continue;
+ }
+ sscanf(buf,"%d %x",&koi,&iso);
+ if (koi < 128 || koi > 255 || iso < 128 || iso > 255) {
+ fprintf(stderr,"invalid value %d\n",koi);
+ exit(1);
+ }
+ koitab[koi-128] = iso;
+ isotab[iso-128] = koi;
+ }
+
+ i = 0;
+ printf("static char koi2iso[] = {\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 iso2koi[] = {\n");
+ while (i < 128) {
+ int j = 0;
+ while (j < 8) {
+ printf("0x%02x",isotab[i++]);
+ j++;
+ if (i >= 128) {
+ break;
+ }
+ printf(", ");
+ }
+ printf("\n");
+ }
+ printf("};\n");
+}
diff --git a/src/backend/utils/mb/win.c b/src/backend/utils/mb/win.c
new file mode 100644
index 00000000000..272c6a638c1
--- /dev/null
+++ b/src/backend/utils/mb/win.c
@@ -0,0 +1,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");
+}