From 3bdd67a20394288761528cf8d5bd77d629cde500 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Fri, 7 Sep 2001 03:32:11 +0000 Subject: [PATCH] Add missing files. --- src/backend/utils/mb/Unicode/alt_to_utf8.map | 130 +++++++++ .../utils/mb/Unicode/koi8r_to_utf8.map | 130 +++++++++ src/backend/utils/mb/Unicode/utf8_to_alt.map | 130 +++++++++ .../utils/mb/Unicode/utf8_to_koi8r.map | 130 +++++++++ .../utils/mb/Unicode/utf8_to_win1251.map | 129 +++++++++ .../utils/mb/Unicode/win1251_to_utf8.map | 130 +++++++++ src/backend/utils/mb/encnames.c | 264 ++++++++++++++++++ src/backend/utils/mb/win1251.c | 74 +++++ 8 files changed, 1117 insertions(+) create mode 100644 src/backend/utils/mb/Unicode/alt_to_utf8.map create mode 100644 src/backend/utils/mb/Unicode/koi8r_to_utf8.map create mode 100644 src/backend/utils/mb/Unicode/utf8_to_alt.map create mode 100644 src/backend/utils/mb/Unicode/utf8_to_koi8r.map create mode 100644 src/backend/utils/mb/Unicode/utf8_to_win1251.map create mode 100644 src/backend/utils/mb/Unicode/win1251_to_utf8.map create mode 100644 src/backend/utils/mb/encnames.c create mode 100644 src/backend/utils/mb/win1251.c diff --git a/src/backend/utils/mb/Unicode/alt_to_utf8.map b/src/backend/utils/mb/Unicode/alt_to_utf8.map new file mode 100644 index 0000000000..7bc6982224 --- /dev/null +++ b/src/backend/utils/mb/Unicode/alt_to_utf8.map @@ -0,0 +1,130 @@ +static pg_local_to_utf LUmapALT[ 128 ] = { + {0x0080, 0xd090}, + {0x0081, 0xd091}, + {0x0082, 0xd092}, + {0x0083, 0xd093}, + {0x0084, 0xd094}, + {0x0085, 0xd095}, + {0x0086, 0xd096}, + {0x0087, 0xd097}, + {0x0088, 0xd098}, + {0x0089, 0xd099}, + {0x008a, 0xd09a}, + {0x008b, 0xd09b}, + {0x008c, 0xd09c}, + {0x008d, 0xd09d}, + {0x008e, 0xd09e}, + {0x008f, 0xd09f}, + {0x0090, 0xd0a0}, + {0x0091, 0xd0a1}, + {0x0092, 0xd0a2}, + {0x0093, 0xd0a3}, + {0x0094, 0xd0a4}, + {0x0095, 0xd0a5}, + {0x0096, 0xd0a6}, + {0x0097, 0xd0a7}, + {0x0098, 0xd0a8}, + {0x0099, 0xd0a9}, + {0x009a, 0xd0aa}, + {0x009b, 0xd0ab}, + {0x009c, 0xd0ac}, + {0x009d, 0xd0ad}, + {0x009e, 0xd0ae}, + {0x009f, 0xd0af}, + {0x00a0, 0xd0b0}, + {0x00a1, 0xd0b1}, + {0x00a2, 0xd0b2}, + {0x00a3, 0xd0b3}, + {0x00a4, 0xd0b4}, + {0x00a5, 0xd0b5}, + {0x00a6, 0xd0b6}, + {0x00a7, 0xd0b7}, + {0x00a8, 0xd0b8}, + {0x00a9, 0xd0b9}, + {0x00aa, 0xd0ba}, + {0x00ab, 0xd0bb}, + {0x00ac, 0xd0bc}, + {0x00ad, 0xd0bd}, + {0x00ae, 0xd0be}, + {0x00af, 0xd0bf}, + {0x00b0, 0xe29691}, + {0x00b1, 0xe29692}, + {0x00b2, 0xe29693}, + {0x00b3, 0xe29482}, + {0x00b4, 0xe294a4}, + {0x00b5, 0xe295a1}, + {0x00b6, 0xe295a2}, + {0x00b7, 0xe29596}, + {0x00b8, 0xe29595}, + {0x00b9, 0xe295a3}, + {0x00ba, 0xe29591}, + {0x00bb, 0xe29597}, + {0x00bc, 0xe2959d}, + {0x00bd, 0xe2959c}, + {0x00be, 0xe2959b}, + {0x00bf, 0xe29490}, + {0x00c0, 0xe29494}, + {0x00c1, 0xe294b4}, + {0x00c2, 0xe294ac}, + {0x00c3, 0xe2949c}, + {0x00c4, 0xe29480}, + {0x00c5, 0xe294bc}, + {0x00c6, 0xe2959e}, + {0x00c7, 0xe2959f}, + {0x00c8, 0xe2959a}, + {0x00c9, 0xe29594}, + {0x00ca, 0xe295a9}, + {0x00cb, 0xe295a6}, + {0x00cc, 0xe295a0}, + {0x00cd, 0xe29590}, + {0x00ce, 0xe295ac}, + {0x00cf, 0xe295a7}, + {0x00d0, 0xe295a8}, + {0x00d1, 0xe295a4}, + {0x00d2, 0xe295a5}, + {0x00d3, 0xe29599}, + {0x00d4, 0xe29598}, + {0x00d5, 0xe29592}, + {0x00d6, 0xe29593}, + {0x00d7, 0xe295ab}, + {0x00d8, 0xe295aa}, + {0x00d9, 0xe29498}, + {0x00da, 0xe2948c}, + {0x00db, 0xe29688}, + {0x00dc, 0xe29684}, + {0x00dd, 0xe2968c}, + {0x00de, 0xe29690}, + {0x00df, 0xe29680}, + {0x00e0, 0xd180}, + {0x00e1, 0xd181}, + {0x00e2, 0xd182}, + {0x00e3, 0xd183}, + {0x00e4, 0xd184}, + {0x00e5, 0xd185}, + {0x00e6, 0xd186}, + {0x00e7, 0xd187}, + {0x00e8, 0xd188}, + {0x00e9, 0xd189}, + {0x00ea, 0xd18a}, + {0x00eb, 0xd18b}, + {0x00ec, 0xd18c}, + {0x00ed, 0xd18d}, + {0x00ee, 0xd18e}, + {0x00ef, 0xd18f}, + {0x00f0, 0xd081}, + {0x00f1, 0xd191}, + {0x00f2, 0xd084}, + {0x00f3, 0xd194}, + {0x00f4, 0xd087}, + {0x00f5, 0xd197}, + {0x00f6, 0xd08e}, + {0x00f7, 0xd19e}, + {0x00f8, 0xc2b0}, + {0x00f9, 0xe28899}, + {0x00fa, 0xc2b7}, + {0x00fb, 0xe2889a}, + {0x00fc, 0xe28496}, + {0x00fd, 0xc2a4}, + {0x00fe, 0xe296a0}, + {0x00ff, 0xc2a0} +}; diff --git a/src/backend/utils/mb/Unicode/koi8r_to_utf8.map b/src/backend/utils/mb/Unicode/koi8r_to_utf8.map new file mode 100644 index 0000000000..e8eaa7095f --- /dev/null +++ b/src/backend/utils/mb/Unicode/koi8r_to_utf8.map @@ -0,0 +1,130 @@ +static pg_local_to_utf LUmapKOI8R[ 128 ] = { + {0x0080, 0xe29480}, + {0x0081, 0xe29482}, + {0x0082, 0xe2948c}, + {0x0083, 0xe29490}, + {0x0084, 0xe29494}, + {0x0085, 0xe29498}, + {0x0086, 0xe2949c}, + {0x0087, 0xe294a4}, + {0x0088, 0xe294ac}, + {0x0089, 0xe294b4}, + {0x008a, 0xe294bc}, + {0x008b, 0xe29680}, + {0x008c, 0xe29684}, + {0x008d, 0xe29688}, + {0x008e, 0xe2968c}, + {0x008f, 0xe29690}, + {0x0090, 0xe29691}, + {0x0091, 0xe29692}, + {0x0092, 0xe29693}, + {0x0093, 0xe28ca0}, + {0x0094, 0xe296a0}, + {0x0095, 0xe28899}, + {0x0096, 0xe2889a}, + {0x0097, 0xe28988}, + {0x0098, 0xe289a4}, + {0x0099, 0xe289a5}, + {0x009a, 0xc2a0}, + {0x009b, 0xe28ca1}, + {0x009c, 0xc2b0}, + {0x009d, 0xc2b2}, + {0x009e, 0xc2b7}, + {0x009f, 0xc3b7}, + {0x00a0, 0xe29590}, + {0x00a1, 0xe29591}, + {0x00a2, 0xe29592}, + {0x00a3, 0xd191}, + {0x00a4, 0xd194}, + {0x00a5, 0xe29594}, + {0x00a6, 0xd196}, + {0x00a7, 0xd197}, + {0x00a8, 0xe29597}, + {0x00a9, 0xe29598}, + {0x00aa, 0xe29599}, + {0x00ab, 0xe2959a}, + {0x00ac, 0xe2959b}, + {0x00ad, 0xd291}, + {0x00ae, 0xe2959d}, + {0x00af, 0xe2959e}, + {0x00b0, 0xe2959f}, + {0x00b1, 0xe295a0}, + {0x00b2, 0xe295a1}, + {0x00b3, 0xd081}, + {0x00b4, 0xd084}, + {0x00b5, 0xe295a3}, + {0x00b6, 0xd086}, + {0x00b7, 0xd087}, + {0x00b8, 0xe295a6}, + {0x00b9, 0xe295a7}, + {0x00ba, 0xe295a8}, + {0x00bb, 0xe295a9}, + {0x00bc, 0xe295aa}, + {0x00bd, 0xd290}, + {0x00be, 0xe295ac}, + {0x00bf, 0xc2a9}, + {0x00c0, 0xd18e}, + {0x00c1, 0xd0b0}, + {0x00c2, 0xd0b1}, + {0x00c3, 0xd186}, + {0x00c4, 0xd0b4}, + {0x00c5, 0xd0b5}, + {0x00c6, 0xd184}, + {0x00c7, 0xd0b3}, + {0x00c8, 0xd185}, + {0x00c9, 0xd0b8}, + {0x00ca, 0xd0b9}, + {0x00cb, 0xd0ba}, + {0x00cc, 0xd0bb}, + {0x00cd, 0xd0bc}, + {0x00ce, 0xd0bd}, + {0x00cf, 0xd0be}, + {0x00d0, 0xd0bf}, + {0x00d1, 0xd18f}, + {0x00d2, 0xd180}, + {0x00d3, 0xd181}, + {0x00d4, 0xd182}, + {0x00d5, 0xd183}, + {0x00d6, 0xd0b6}, + {0x00d7, 0xd0b2}, + {0x00d8, 0xd18c}, + {0x00d9, 0xd18b}, + {0x00da, 0xd0b7}, + {0x00db, 0xd188}, + {0x00dc, 0xd18d}, + {0x00dd, 0xd189}, + {0x00de, 0xd187}, + {0x00df, 0xd18a}, + {0x00e0, 0xd0ae}, + {0x00e1, 0xd090}, + {0x00e2, 0xd091}, + {0x00e3, 0xd0a6}, + {0x00e4, 0xd094}, + {0x00e5, 0xd095}, + {0x00e6, 0xd0a4}, + {0x00e7, 0xd093}, + {0x00e8, 0xd0a5}, + {0x00e9, 0xd098}, + {0x00ea, 0xd099}, + {0x00eb, 0xd09a}, + {0x00ec, 0xd09b}, + {0x00ed, 0xd09c}, + {0x00ee, 0xd09d}, + {0x00ef, 0xd09e}, + {0x00f0, 0xd09f}, + {0x00f1, 0xd0af}, + {0x00f2, 0xd0a0}, + {0x00f3, 0xd0a1}, + {0x00f4, 0xd0a2}, + {0x00f5, 0xd0a3}, + {0x00f6, 0xd096}, + {0x00f7, 0xd092}, + {0x00f8, 0xd0ac}, + {0x00f9, 0xd0ab}, + {0x00fa, 0xd097}, + {0x00fb, 0xd0a8}, + {0x00fc, 0xd0ad}, + {0x00fd, 0xd0a9}, + {0x00fe, 0xd0a7}, + {0x00ff, 0xd0aa} +}; diff --git a/src/backend/utils/mb/Unicode/utf8_to_alt.map b/src/backend/utils/mb/Unicode/utf8_to_alt.map new file mode 100644 index 0000000000..2aba0c5a9b --- /dev/null +++ b/src/backend/utils/mb/Unicode/utf8_to_alt.map @@ -0,0 +1,130 @@ +static pg_utf_to_local ULmap_ALT[ 128 ] = { + {0xc2a0, 0x00ff}, + {0xc2a4, 0x00fd}, + {0xc2b0, 0x00f8}, + {0xc2b7, 0x00fa}, + {0xd081, 0x00f0}, + {0xd084, 0x00f2}, + {0xd087, 0x00f4}, + {0xd08e, 0x00f6}, + {0xd090, 0x0080}, + {0xd091, 0x0081}, + {0xd092, 0x0082}, + {0xd093, 0x0083}, + {0xd094, 0x0084}, + {0xd095, 0x0085}, + {0xd096, 0x0086}, + {0xd097, 0x0087}, + {0xd098, 0x0088}, + {0xd099, 0x0089}, + {0xd09a, 0x008a}, + {0xd09b, 0x008b}, + {0xd09c, 0x008c}, + {0xd09d, 0x008d}, + {0xd09e, 0x008e}, + {0xd09f, 0x008f}, + {0xd0a0, 0x0090}, + {0xd0a1, 0x0091}, + {0xd0a2, 0x0092}, + {0xd0a3, 0x0093}, + {0xd0a4, 0x0094}, + {0xd0a5, 0x0095}, + {0xd0a6, 0x0096}, + {0xd0a7, 0x0097}, + {0xd0a8, 0x0098}, + {0xd0a9, 0x0099}, + {0xd0aa, 0x009a}, + {0xd0ab, 0x009b}, + {0xd0ac, 0x009c}, + {0xd0ad, 0x009d}, + {0xd0ae, 0x009e}, + {0xd0af, 0x009f}, + {0xd0b0, 0x00a0}, + {0xd0b1, 0x00a1}, + {0xd0b2, 0x00a2}, + {0xd0b3, 0x00a3}, + {0xd0b4, 0x00a4}, + {0xd0b5, 0x00a5}, + {0xd0b6, 0x00a6}, + {0xd0b7, 0x00a7}, + {0xd0b8, 0x00a8}, + {0xd0b9, 0x00a9}, + {0xd0ba, 0x00aa}, + {0xd0bb, 0x00ab}, + {0xd0bc, 0x00ac}, + {0xd0bd, 0x00ad}, + {0xd0be, 0x00ae}, + {0xd0bf, 0x00af}, + {0xd180, 0x00e0}, + {0xd181, 0x00e1}, + {0xd182, 0x00e2}, + {0xd183, 0x00e3}, + {0xd184, 0x00e4}, + {0xd185, 0x00e5}, + {0xd186, 0x00e6}, + {0xd187, 0x00e7}, + {0xd188, 0x00e8}, + {0xd189, 0x00e9}, + {0xd18a, 0x00ea}, + {0xd18b, 0x00eb}, + {0xd18c, 0x00ec}, + {0xd18d, 0x00ed}, + {0xd18e, 0x00ee}, + {0xd18f, 0x00ef}, + {0xd191, 0x00f1}, + {0xd194, 0x00f3}, + {0xd197, 0x00f5}, + {0xd19e, 0x00f7}, + {0xe28496, 0x00fc}, + {0xe28899, 0x00f9}, + {0xe2889a, 0x00fb}, + {0xe29480, 0x00c4}, + {0xe29482, 0x00b3}, + {0xe2948c, 0x00da}, + {0xe29490, 0x00bf}, + {0xe29494, 0x00c0}, + {0xe29498, 0x00d9}, + {0xe2949c, 0x00c3}, + {0xe294a4, 0x00b4}, + {0xe294ac, 0x00c2}, + {0xe294b4, 0x00c1}, + {0xe294bc, 0x00c5}, + {0xe29590, 0x00cd}, + {0xe29591, 0x00ba}, + {0xe29592, 0x00d5}, + {0xe29593, 0x00d6}, + {0xe29594, 0x00c9}, + {0xe29595, 0x00b8}, + {0xe29596, 0x00b7}, + {0xe29597, 0x00bb}, + {0xe29598, 0x00d4}, + {0xe29599, 0x00d3}, + {0xe2959a, 0x00c8}, + {0xe2959b, 0x00be}, + {0xe2959c, 0x00bd}, + {0xe2959d, 0x00bc}, + {0xe2959e, 0x00c6}, + {0xe2959f, 0x00c7}, + {0xe295a0, 0x00cc}, + {0xe295a1, 0x00b5}, + {0xe295a2, 0x00b6}, + {0xe295a3, 0x00b9}, + {0xe295a4, 0x00d1}, + {0xe295a5, 0x00d2}, + {0xe295a6, 0x00cb}, + {0xe295a7, 0x00cf}, + {0xe295a8, 0x00d0}, + {0xe295a9, 0x00ca}, + {0xe295aa, 0x00d8}, + {0xe295ab, 0x00d7}, + {0xe295ac, 0x00ce}, + {0xe29680, 0x00df}, + {0xe29684, 0x00dc}, + {0xe29688, 0x00db}, + {0xe2968c, 0x00dd}, + {0xe29690, 0x00de}, + {0xe29691, 0x00b0}, + {0xe29692, 0x00b1}, + {0xe29693, 0x00b2}, + {0xe296a0, 0x00fe} +}; diff --git a/src/backend/utils/mb/Unicode/utf8_to_koi8r.map b/src/backend/utils/mb/Unicode/utf8_to_koi8r.map new file mode 100644 index 0000000000..2134ec280f --- /dev/null +++ b/src/backend/utils/mb/Unicode/utf8_to_koi8r.map @@ -0,0 +1,130 @@ +static pg_utf_to_local ULmap_KOI8R[ 128 ] = { + {0xc2a0, 0x009a}, + {0xc2a9, 0x00bf}, + {0xc2b0, 0x009c}, + {0xc2b2, 0x009d}, + {0xc2b7, 0x009e}, + {0xc3b7, 0x009f}, + {0xd081, 0x00b3}, + {0xd084, 0x00b4}, + {0xd086, 0x00b6}, + {0xd087, 0x00b7}, + {0xd090, 0x00e1}, + {0xd091, 0x00e2}, + {0xd092, 0x00f7}, + {0xd093, 0x00e7}, + {0xd094, 0x00e4}, + {0xd095, 0x00e5}, + {0xd096, 0x00f6}, + {0xd097, 0x00fa}, + {0xd098, 0x00e9}, + {0xd099, 0x00ea}, + {0xd09a, 0x00eb}, + {0xd09b, 0x00ec}, + {0xd09c, 0x00ed}, + {0xd09d, 0x00ee}, + {0xd09e, 0x00ef}, + {0xd09f, 0x00f0}, + {0xd0a0, 0x00f2}, + {0xd0a1, 0x00f3}, + {0xd0a2, 0x00f4}, + {0xd0a3, 0x00f5}, + {0xd0a4, 0x00e6}, + {0xd0a5, 0x00e8}, + {0xd0a6, 0x00e3}, + {0xd0a7, 0x00fe}, + {0xd0a8, 0x00fb}, + {0xd0a9, 0x00fd}, + {0xd0aa, 0x00ff}, + {0xd0ab, 0x00f9}, + {0xd0ac, 0x00f8}, + {0xd0ad, 0x00fc}, + {0xd0ae, 0x00e0}, + {0xd0af, 0x00f1}, + {0xd0b0, 0x00c1}, + {0xd0b1, 0x00c2}, + {0xd0b2, 0x00d7}, + {0xd0b3, 0x00c7}, + {0xd0b4, 0x00c4}, + {0xd0b5, 0x00c5}, + {0xd0b6, 0x00d6}, + {0xd0b7, 0x00da}, + {0xd0b8, 0x00c9}, + {0xd0b9, 0x00ca}, + {0xd0ba, 0x00cb}, + {0xd0bb, 0x00cc}, + {0xd0bc, 0x00cd}, + {0xd0bd, 0x00ce}, + {0xd0be, 0x00cf}, + {0xd0bf, 0x00d0}, + {0xd180, 0x00d2}, + {0xd181, 0x00d3}, + {0xd182, 0x00d4}, + {0xd183, 0x00d5}, + {0xd184, 0x00c6}, + {0xd185, 0x00c8}, + {0xd186, 0x00c3}, + {0xd187, 0x00de}, + {0xd188, 0x00db}, + {0xd189, 0x00dd}, + {0xd18a, 0x00df}, + {0xd18b, 0x00d9}, + {0xd18c, 0x00d8}, + {0xd18d, 0x00dc}, + {0xd18e, 0x00c0}, + {0xd18f, 0x00d1}, + {0xd191, 0x00a3}, + {0xd194, 0x00a4}, + {0xd196, 0x00a6}, + {0xd197, 0x00a7}, + {0xd290, 0x00bd}, + {0xd291, 0x00ad}, + {0xe28899, 0x0095}, + {0xe2889a, 0x0096}, + {0xe28988, 0x0097}, + {0xe289a4, 0x0098}, + {0xe289a5, 0x0099}, + {0xe28ca0, 0x0093}, + {0xe28ca1, 0x009b}, + {0xe29480, 0x0080}, + {0xe29482, 0x0081}, + {0xe2948c, 0x0082}, + {0xe29490, 0x0083}, + {0xe29494, 0x0084}, + {0xe29498, 0x0085}, + {0xe2949c, 0x0086}, + {0xe294a4, 0x0087}, + {0xe294ac, 0x0088}, + {0xe294b4, 0x0089}, + {0xe294bc, 0x008a}, + {0xe29590, 0x00a0}, + {0xe29591, 0x00a1}, + {0xe29592, 0x00a2}, + {0xe29594, 0x00a5}, + {0xe29597, 0x00a8}, + {0xe29598, 0x00a9}, + {0xe29599, 0x00aa}, + {0xe2959a, 0x00ab}, + {0xe2959b, 0x00ac}, + {0xe2959d, 0x00ae}, + {0xe2959e, 0x00af}, + {0xe2959f, 0x00b0}, + {0xe295a0, 0x00b1}, + {0xe295a1, 0x00b2}, + {0xe295a3, 0x00b5}, + {0xe295a6, 0x00b8}, + {0xe295a7, 0x00b9}, + {0xe295a8, 0x00ba}, + {0xe295a9, 0x00bb}, + {0xe295aa, 0x00bc}, + {0xe295ac, 0x00be}, + {0xe29680, 0x008b}, + {0xe29684, 0x008c}, + {0xe29688, 0x008d}, + {0xe2968c, 0x008e}, + {0xe29690, 0x008f}, + {0xe29691, 0x0090}, + {0xe29692, 0x0091}, + {0xe29693, 0x0092}, + {0xe296a0, 0x0094} +}; diff --git a/src/backend/utils/mb/Unicode/utf8_to_win1251.map b/src/backend/utils/mb/Unicode/utf8_to_win1251.map new file mode 100644 index 0000000000..434c3f88f6 --- /dev/null +++ b/src/backend/utils/mb/Unicode/utf8_to_win1251.map @@ -0,0 +1,129 @@ +static pg_utf_to_local ULmap_WIN1251[ 127 ] = { + {0x0000, 0x0088}, + {0xc2a0, 0x00a0}, + {0xc2a4, 0x00a4}, + {0xc2a6, 0x00a6}, + {0xc2a7, 0x00a7}, + {0xc2a9, 0x00a9}, + {0xc2ab, 0x00ab}, + {0xc2ac, 0x00ac}, + {0xc2ad, 0x00ad}, + {0xc2ae, 0x00ae}, + {0xc2b0, 0x00b0}, + {0xc2b1, 0x00b1}, + {0xc2b5, 0x00b5}, + {0xc2b6, 0x00b6}, + {0xc2b7, 0x00b7}, + {0xc2bb, 0x00bb}, + {0xd081, 0x00a8}, + {0xd082, 0x0080}, + {0xd083, 0x0081}, + {0xd084, 0x00aa}, + {0xd085, 0x00bd}, + {0xd086, 0x00b2}, + {0xd087, 0x00af}, + {0xd088, 0x00a3}, + {0xd089, 0x008a}, + {0xd08a, 0x008c}, + {0xd08b, 0x008e}, + {0xd08c, 0x008d}, + {0xd08e, 0x00a1}, + {0xd08f, 0x008f}, + {0xd090, 0x00c0}, + {0xd091, 0x00c1}, + {0xd092, 0x00c2}, + {0xd093, 0x00c3}, + {0xd094, 0x00c4}, + {0xd095, 0x00c5}, + {0xd096, 0x00c6}, + {0xd097, 0x00c7}, + {0xd098, 0x00c8}, + {0xd099, 0x00c9}, + {0xd09a, 0x00ca}, + {0xd09b, 0x00cb}, + {0xd09c, 0x00cc}, + {0xd09d, 0x00cd}, + {0xd09e, 0x00ce}, + {0xd09f, 0x00cf}, + {0xd0a0, 0x00d0}, + {0xd0a1, 0x00d1}, + {0xd0a2, 0x00d2}, + {0xd0a3, 0x00d3}, + {0xd0a4, 0x00d4}, + {0xd0a5, 0x00d5}, + {0xd0a6, 0x00d6}, + {0xd0a7, 0x00d7}, + {0xd0a8, 0x00d8}, + {0xd0a9, 0x00d9}, + {0xd0aa, 0x00da}, + {0xd0ab, 0x00db}, + {0xd0ac, 0x00dc}, + {0xd0ad, 0x00dd}, + {0xd0ae, 0x00de}, + {0xd0af, 0x00df}, + {0xd0b0, 0x00e0}, + {0xd0b1, 0x00e1}, + {0xd0b2, 0x00e2}, + {0xd0b3, 0x00e3}, + {0xd0b4, 0x00e4}, + {0xd0b5, 0x00e5}, + {0xd0b6, 0x00e6}, + {0xd0b7, 0x00e7}, + {0xd0b8, 0x00e8}, + {0xd0b9, 0x00e9}, + {0xd0ba, 0x00ea}, + {0xd0bb, 0x00eb}, + {0xd0bc, 0x00ec}, + {0xd0bd, 0x00ed}, + {0xd0be, 0x00ee}, + {0xd0bf, 0x00ef}, + {0xd180, 0x00f0}, + {0xd181, 0x00f1}, + {0xd182, 0x00f2}, + {0xd183, 0x00f3}, + {0xd184, 0x00f4}, + {0xd185, 0x00f5}, + {0xd186, 0x00f6}, + {0xd187, 0x00f7}, + {0xd188, 0x00f8}, + {0xd189, 0x00f9}, + {0xd18a, 0x00fa}, + {0xd18b, 0x00fb}, + {0xd18c, 0x00fc}, + {0xd18d, 0x00fd}, + {0xd18e, 0x00fe}, + {0xd18f, 0x00ff}, + {0xd191, 0x00b8}, + {0xd192, 0x0090}, + {0xd193, 0x0083}, + {0xd194, 0x00ba}, + {0xd195, 0x00be}, + {0xd196, 0x00b3}, + {0xd197, 0x00bf}, + {0xd198, 0x00bc}, + {0xd199, 0x009a}, + {0xd19a, 0x009c}, + {0xd19b, 0x009e}, + {0xd19c, 0x009d}, + {0xd19e, 0x00a2}, + {0xd19f, 0x009f}, + {0xd290, 0x00a5}, + {0xd291, 0x00b4}, + {0xe28093, 0x0096}, + {0xe28094, 0x0097}, + {0xe28098, 0x0091}, + {0xe28099, 0x0092}, + {0xe2809a, 0x0082}, + {0xe2809c, 0x0093}, + {0xe2809d, 0x0094}, + {0xe2809e, 0x0084}, + {0xe280a0, 0x0086}, + {0xe280a1, 0x0087}, + {0xe280a2, 0x0095}, + {0xe280a6, 0x0085}, + {0xe280b0, 0x0089}, + {0xe280b9, 0x008b}, + {0xe280ba, 0x009b}, + {0xe28496, 0x00b9}, + {0xe284a2, 0x0099} +}; diff --git a/src/backend/utils/mb/Unicode/win1251_to_utf8.map b/src/backend/utils/mb/Unicode/win1251_to_utf8.map new file mode 100644 index 0000000000..855575cd51 --- /dev/null +++ b/src/backend/utils/mb/Unicode/win1251_to_utf8.map @@ -0,0 +1,130 @@ +static pg_local_to_utf LUmapWIN1251[ 128 ] = { + {0x0080, 0xd082}, + {0x0081, 0xd083}, + {0x0082, 0xe2809a}, + {0x0083, 0xd193}, + {0x0084, 0xe2809e}, + {0x0085, 0xe280a6}, + {0x0086, 0xe280a0}, + {0x0087, 0xe280a1}, + {0x0088, 0x0000}, + {0x0089, 0xe280b0}, + {0x008a, 0xd089}, + {0x008b, 0xe280b9}, + {0x008c, 0xd08a}, + {0x008d, 0xd08c}, + {0x008e, 0xd08b}, + {0x008f, 0xd08f}, + {0x0090, 0xd192}, + {0x0091, 0xe28098}, + {0x0092, 0xe28099}, + {0x0093, 0xe2809c}, + {0x0094, 0xe2809d}, + {0x0095, 0xe280a2}, + {0x0096, 0xe28093}, + {0x0097, 0xe28094}, + {0x0098, 0x0000}, + {0x0099, 0xe284a2}, + {0x009a, 0xd199}, + {0x009b, 0xe280ba}, + {0x009c, 0xd19a}, + {0x009d, 0xd19c}, + {0x009e, 0xd19b}, + {0x009f, 0xd19f}, + {0x00a0, 0xc2a0}, + {0x00a1, 0xd08e}, + {0x00a2, 0xd19e}, + {0x00a3, 0xd088}, + {0x00a4, 0xc2a4}, + {0x00a5, 0xd290}, + {0x00a6, 0xc2a6}, + {0x00a7, 0xc2a7}, + {0x00a8, 0xd081}, + {0x00a9, 0xc2a9}, + {0x00aa, 0xd084}, + {0x00ab, 0xc2ab}, + {0x00ac, 0xc2ac}, + {0x00ad, 0xc2ad}, + {0x00ae, 0xc2ae}, + {0x00af, 0xd087}, + {0x00b0, 0xc2b0}, + {0x00b1, 0xc2b1}, + {0x00b2, 0xd086}, + {0x00b3, 0xd196}, + {0x00b4, 0xd291}, + {0x00b5, 0xc2b5}, + {0x00b6, 0xc2b6}, + {0x00b7, 0xc2b7}, + {0x00b8, 0xd191}, + {0x00b9, 0xe28496}, + {0x00ba, 0xd194}, + {0x00bb, 0xc2bb}, + {0x00bc, 0xd198}, + {0x00bd, 0xd085}, + {0x00be, 0xd195}, + {0x00bf, 0xd197}, + {0x00c0, 0xd090}, + {0x00c1, 0xd091}, + {0x00c2, 0xd092}, + {0x00c3, 0xd093}, + {0x00c4, 0xd094}, + {0x00c5, 0xd095}, + {0x00c6, 0xd096}, + {0x00c7, 0xd097}, + {0x00c8, 0xd098}, + {0x00c9, 0xd099}, + {0x00ca, 0xd09a}, + {0x00cb, 0xd09b}, + {0x00cc, 0xd09c}, + {0x00cd, 0xd09d}, + {0x00ce, 0xd09e}, + {0x00cf, 0xd09f}, + {0x00d0, 0xd0a0}, + {0x00d1, 0xd0a1}, + {0x00d2, 0xd0a2}, + {0x00d3, 0xd0a3}, + {0x00d4, 0xd0a4}, + {0x00d5, 0xd0a5}, + {0x00d6, 0xd0a6}, + {0x00d7, 0xd0a7}, + {0x00d8, 0xd0a8}, + {0x00d9, 0xd0a9}, + {0x00da, 0xd0aa}, + {0x00db, 0xd0ab}, + {0x00dc, 0xd0ac}, + {0x00dd, 0xd0ad}, + {0x00de, 0xd0ae}, + {0x00df, 0xd0af}, + {0x00e0, 0xd0b0}, + {0x00e1, 0xd0b1}, + {0x00e2, 0xd0b2}, + {0x00e3, 0xd0b3}, + {0x00e4, 0xd0b4}, + {0x00e5, 0xd0b5}, + {0x00e6, 0xd0b6}, + {0x00e7, 0xd0b7}, + {0x00e8, 0xd0b8}, + {0x00e9, 0xd0b9}, + {0x00ea, 0xd0ba}, + {0x00eb, 0xd0bb}, + {0x00ec, 0xd0bc}, + {0x00ed, 0xd0bd}, + {0x00ee, 0xd0be}, + {0x00ef, 0xd0bf}, + {0x00f0, 0xd180}, + {0x00f1, 0xd181}, + {0x00f2, 0xd182}, + {0x00f3, 0xd183}, + {0x00f4, 0xd184}, + {0x00f5, 0xd185}, + {0x00f6, 0xd186}, + {0x00f7, 0xd187}, + {0x00f8, 0xd188}, + {0x00f9, 0xd189}, + {0x00fa, 0xd18a}, + {0x00fb, 0xd18b}, + {0x00fc, 0xd18c}, + {0x00fd, 0xd18d}, + {0x00fe, 0xd18e}, + {0x00ff, 0xd18f} +}; diff --git a/src/backend/utils/mb/encnames.c b/src/backend/utils/mb/encnames.c new file mode 100644 index 0000000000..f7b0ea3a34 --- /dev/null +++ b/src/backend/utils/mb/encnames.c @@ -0,0 +1,264 @@ +/* + * Encoding names and routines for work with it. All + * in this file is shared bedween FE and BE. + * + * $Id: encnames.c,v 1.1 2001/09/07 03:32:11 ishii Exp $ + */ +#ifdef FRONTEND +#include "postgres_fe.h" +#define Assert(condition) +#else +#include "postgres.h" +#include "miscadmin.h" +#include "utils/builtins.h" +#endif + +#ifdef WIN32 +#include "win32.h" +#else +#include +#endif + +#include "mb/pg_wchar.h" +#include + +/* + * Debug + */ +/* #define DEBUG_ENCODING */ +#ifdef DEBUG_ENCODING +#ifdef FRONTEND +#define encdebug(_format, _a...) fprintf(stderr, _format, ##_a) +#else +#define encdebug(_format, _a...) elog(NOTICE, _format, ##_a) +#endif +#else +#define encdebug(_format, _a...) +#endif + +/* ---------- + * All encoding names, sorted: *** A L P H A B E T I C *** + * + * All names must be without irrelevan chars, search routines use + * isalnum() chars only. It means ISO-8859-1, iso_8859-1 and Iso8859_1 + * are always converted to 'iso88591'. All must be lower case. + * + * The table doesn't contain 'cs' aliases (like csISOLatin1). It's needful? + * + * Karel Zak, Aug 2001 + * ---------- + */ +pg_encname pg_encname_tbl[] = +{ + { "alt", PG_ALT }, /* IBM866 */ + { "big5", PG_BIG5 }, /* Big5; Chinese for Taiwan Multi-byte set */ + { "euccn", PG_EUC_CN }, /* EUC-CN; ??? */ + { "eucjp", PG_EUC_JP }, /* EUC-JP; Extended UNIX Code Fixed Width for Japanese, stdandard OSF */ + { "euckr", PG_EUC_KR }, /* EUC-KR; RFC1557,Choi */ + { "euctw", PG_EUC_TW }, /* EUC-TW; ??? */ + { "iso88591", PG_LATIN1 }, /* ISO-8859-1; RFC1345,KXS2 */ + { "iso88592", PG_LATIN2 }, /* ISO-8859-2; RFC1345,KXS2 */ + { "iso88593", PG_LATIN3 }, /* ISO-8859-3; RFC1345,KXS2 */ + { "iso88594", PG_LATIN4 }, /* ISO-8859-4; RFC1345,KXS2 */ + { "iso88595", PG_LATIN5 }, /* ISO-8859-5; RFC1345,KXS2 */ + { "koi8", PG_KOI8R }, /* _dirty_ alias for KOI8-R (back compatibility) */ + { "koi8r", PG_KOI8R }, /* KOI8-R; RFC1489 */ + { "latin1", PG_LATIN1 }, /* alias for ISO-8859-1 */ + { "latin2", PG_LATIN2 }, /* alias for ISO-8859-2 */ + { "latin3", PG_LATIN3 }, /* alias for ISO-8859-3 */ + { "latin4", PG_LATIN4 }, /* alias for ISO-8859-4 */ + { "latin5", PG_LATIN5 }, /* alias for ISO-8859-5 */ + { "mskanji", PG_SJIS }, /* alias for Shift_JIS */ + { "muleinternal",PG_MULE_INTERNAL }, + { "shiftjis", PG_SJIS }, /* Shift_JIS; JIS X 0202-1991 */ + { "sjis", PG_SJIS }, /* alias for Shift_JIS */ + { "sqlascii", PG_SQL_ASCII }, + { "unicode", PG_UTF8 }, /* alias for UTF-8 */ + { "utf8", PG_UTF8 }, /* UTF-8; RFC2279 */ + { "win", PG_WIN1251 }, /* _dirty_ alias for windows-1251 (back compatibility) */ + { "win1250", PG_WIN1250 }, /* alias for Windows-1250 */ + { "win1251", PG_WIN1251 }, /* alias for Windows-1251 */ + { "windows1250",PG_WIN1250 }, /* Windows-1251; Microsoft */ + { "windows1251",PG_WIN1251 }, /* Windows-1251; Microsoft */ + + { NULL, 0 } /* last */ +}; + +unsigned int pg_encname_tbl_sz = \ + sizeof(pg_encname_tbl) / sizeof(pg_encname_tbl[0]) -1; + +/* ---------- + * WARNING: sorted by pg_enc enum (pg_wchar.h)! + * ---------- + */ +pg_enc2name pg_enc2name_tbl[] = +{ + { "SQL_ASCII", PG_SQL_ASCII }, + { "EUC_JP", PG_EUC_JP }, + { "EUC_CN", PG_EUC_CN }, + { "EUC_KR", PG_EUC_KR }, + { "EUC_TW", PG_EUC_TW }, + { "UNICODE", PG_UTF8 }, + { "MULE_INTERNAL",PG_MULE_INTERNAL }, + { "LATIN1", PG_LATIN1 }, + { "LATIN2", PG_LATIN2 }, + { "LATIN3", PG_LATIN3 }, + { "LATIN4", PG_LATIN4 }, + { "LATIN5", PG_LATIN5 }, + { "KOI8", PG_KOI8R }, + { "WIN", PG_WIN1251 }, + { "ALT", PG_ALT }, + { "SJIS", PG_SJIS }, + { "BIG5", PG_BIG5 }, + { "WIN1250", PG_WIN1250 } +}; + +/* ---------- + * Encoding checks, for error returns -1 else encoding id + * ---------- + */ +int +pg_valid_client_encoding(const char *name) +{ + int enc; + + if ((enc = pg_char_to_encoding(name)) < 0) + return -1; + + if (!PG_VALID_FE_ENCODING( enc)) + return -1; + + return enc; +} + +int +pg_valid_server_encoding(const char *name) +{ + int enc; + + if ((enc = pg_char_to_encoding(name)) < 0) + return -1; + + if (!PG_VALID_BE_ENCODING( enc)) + return -1; + + return enc; +} + +/* ---------- + * Remove irrelevant chars from encoding name + * ---------- + */ +static char * +clean_encoding_name(char *key, char *newkey) +{ + char *p, *np; + + for(p=key, np=newkey; *p!='\0'; p++) + { + if (isalnum((unsigned char) *p)) + *np++=tolower((unsigned char) *p); + } + *np = '\0'; + return newkey; +} + +/* ---------- + * Search encoding by encoding name + * ---------- + */ +pg_encname * +pg_char_to_encname_struct(const char *name) +{ + unsigned int nel = pg_encname_tbl_sz; + pg_encname *base = pg_encname_tbl, + *last = base + nel - 1, + *position; + int result; + char buff[NAMEDATALEN], + *key; + + if(name==NULL || *name=='\0') + return NULL; + + if (strlen(name) > NAMEDATALEN) + { +#ifdef FRONTEND + fprintf(stderr, "pg_char_to_encname_struct(): encoding name too long"); + return NULL; +#else + elog(ERROR, "pg_char_to_encname_struct(): encoding name too long"); +#endif + } + key = clean_encoding_name((char *) name, buff); + + encdebug("Name: %s", key); + + while (last >= base) + { + position = base + ((last - base) >> 1); + result = key[0] - position->name[0]; + + if (result == 0) + { + result = strcmp(key, position->name); + if (result == 0) + return position; + } + if (result < 0) + last = position - 1; + else + base = position + 1; + } + + encdebug("UNKNOWN! encoding"); + return NULL; +} + +/* + * Returns encoding or -1 for error + */ +int +pg_char_to_encoding(const char *s) +{ + pg_encname *p = NULL; + + if (!s) + return (-1); + + p = pg_char_to_encname_struct(s); + return p ? p->encoding : -1; +} + +#ifndef FRONTEND +Datum +PG_char_to_encoding(PG_FUNCTION_ARGS) +{ + Name s = PG_GETARG_NAME(0); + PG_RETURN_INT32(pg_char_to_encoding(NameStr(*s))); +} +#endif + +const char * +pg_encoding_to_char(int encoding) +{ + if (PG_VALID_ENCODING(encoding)) + { + pg_enc2name *p = &pg_enc2name_tbl[ encoding ]; + Assert( encoding == p->encoding ); + return p->name; + } + return ""; +} + +#ifndef FRONTEND +Datum +PG_encoding_to_char(PG_FUNCTION_ARGS) +{ + int32 encoding = PG_GETARG_INT32(0); + const char *encoding_name = pg_encoding_to_char(encoding); + + return DirectFunctionCall1(namein, CStringGetDatum(encoding_name)); +} +#endif + diff --git a/src/backend/utils/mb/win1251.c b/src/backend/utils/mb/win1251.c new file mode 100644 index 0000000000..77368f0576 --- /dev/null +++ b/src/backend/utils/mb/win1251.c @@ -0,0 +1,74 @@ +/* + * make KOI8->CP1251(win-1251) and CP1251(win-1251)->KOI8 translation table + * from koi-win.tab. + * + * Tatsuo Ishii + * + * $Id: win1251.c,v 1.1 2001/09/07 03:32:11 ishii Exp $ + */ + +#include + + +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"); +} -- 2.40.0