diff --git a/src/backend/utils/mb/conv.c b/src/backend/utils/mb/conv.c index ea9b78f252e5ea5de5c1b39d7d9b988ada5029c0..f2730aaea51e5f6deed647f1bb4a987862a7612c 100644 --- a/src/backend/utils/mb/conv.c +++ b/src/backend/utils/mb/conv.c @@ -2,15 +2,21 @@ * conversion between client encoding and server internal encoding * (currently mule internal code (mic) is used) * Tatsuo Ishii - * $Id: conv.c,v 1.11 1999/05/26 15:19:55 momjian Exp $ + * WIN1250 client encoding support contributed by Pavel Behal + * + * $Id: conv.c,v 1.12 1999/07/11 22:47:20 ishii Exp $ + * + * */ + #include <stdio.h> #include <string.h> #include "mb/pg_wchar.h" /* - * convert bogus chars that cannot be represented in the current encoding + * convert bogus chars that cannot be represented in the current +encoding * system. */ static void @@ -557,7 +563,6 @@ mic2latin4(unsigned char *mic, unsigned char *p, int len) { mic2latin(mic, p, len, LC_ISO8859_4); } - #ifdef NOT_USED static void latin52mic(unsigned char *l, unsigned char *p, int len) @@ -724,7 +729,7 @@ mic2latin_with_table( static void iso2mic(unsigned char *l, unsigned char *p, int len) { - static char iso2koi[] = { + static unsigned char iso2koi[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -750,7 +755,7 @@ iso2mic(unsigned char *l, unsigned char *p, int len) static void mic2iso(unsigned char *mic, unsigned char *p, int len) { - static char koi2iso[] = { + static unsigned char koi2iso[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -776,7 +781,7 @@ mic2iso(unsigned char *mic, unsigned char *p, int len) static void win2mic(unsigned char *l, unsigned char *p, int len) { - static char win2koi[] = { + static unsigned char win2koi[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -802,7 +807,7 @@ win2mic(unsigned char *l, unsigned char *p, int len) static void mic2win(unsigned char *mic, unsigned char *p, int len) { - static char koi2win[] = { + static unsigned char koi2win[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -828,7 +833,7 @@ mic2win(unsigned char *mic, unsigned char *p, int len) static void alt2mic(unsigned char *l, unsigned char *p, int len) { - static char alt2koi[] = { + static unsigned char alt2koi[] = { 0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe, @@ -854,7 +859,7 @@ alt2mic(unsigned char *l, unsigned char *p, int len) static void mic2alt(unsigned char *mic, unsigned char *p, int len) { - static char koi2alt[] = { + static unsigned char koi2alt[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -880,6 +885,61 @@ mic2alt(unsigned char *mic, unsigned char *p, int len) * end of Cyrillic support */ + +/*----------------------------------------------------------------- + * WIN1250 + * Microsoft's CP1250(windows-1250) + *-----------------------------------------------------------------*/ +static void +win12502mic(unsigned char *l, unsigned char *p, int len) +{ + static unsigned char win1250_2_iso88592[] = { + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0xA9, 0x8B, 0xA6, 0xAB, 0xAE, 0xAC, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0xB9, 0x9B, 0xB6, 0xBB, 0xBE, 0xBC, + 0xA0, 0xB7, 0xA2, 0xA3, 0xA4, 0xA1, 0x00, 0xA7, + 0xA8, 0x00, 0xAA, 0x00, 0x00, 0xAD, 0x00, 0xAF, + 0xB0, 0x00, 0xB2, 0xB3, 0xB4, 0x00, 0x00, 0x00, + 0xB8, 0xB1, 0xBA, 0x00, 0xA5, 0xBD, 0xB5, 0xBF, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, + 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF + }; + + latin2mic_with_table(l, p, len, LC_ISO8859_2, win1250_2_iso88592); +} +static void +mic2win1250(unsigned char *mic, unsigned char *p, int len) +{ + static unsigned char iso88592_2_win1250[] = { + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x00, 0x8B, 0x00, 0x00, 0x00, 0x00, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x00, 0x9B, 0x00, 0x00, 0x00, 0x00, + 0xA0, 0xA5, 0xA2, 0xA3, 0xA4, 0xBC, 0x8C, 0xA7, + 0xA8, 0x8A, 0xAA, 0x8D, 0x8F, 0xAD, 0x8E, 0xAF, + 0xB0, 0xB9, 0xB2, 0xB3, 0xB4, 0xBE, 0x9C, 0xA1, + 0xB8, 0x9A, 0xBA, 0x9D, 0x9F, 0xBD, 0x9E, 0xBF, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, + 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF + }; + + mic2latin_with_table(mic, p, len, LC_ISO8859_2, iso88592_2_win1250); +} +/*-----------------------------------------------------------------*/ + pg_encoding_conv_tbl pg_conv_tbl[] = { {SQL_ASCII, "SQL_ASCII", 0, ascii2mic, mic2ascii}, /* SQL/ACII */ {EUC_JP, "EUC_JP", 0, euc_jp2mic, mic2euc_jp}, /* EUC_JP */ @@ -898,5 +958,6 @@ pg_encoding_conv_tbl pg_conv_tbl[] = { {ALT, "ALT", 0, alt2mic, mic2alt}, /* CP866 */ {SJIS, "SJIS", 1, sjis2mic, mic2sjis}, /* SJIS */ {BIG5, "BIG5", 1, big52mic, mic2big5}, /* Big5 */ + {WIN1250, "WIN1250", 1, win12502mic, mic2win1250}, /* WIN 1250 */ {-1, "", 0, 0, 0} /* end mark */ }; diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c index 0d557e30f6f5e63a8cd5b5a7805a919ef5fd0a98..0e95b1914b4f59debf4ad7e8563fa9c4b16e2f46 100644 --- a/src/backend/utils/mb/wchar.c +++ b/src/backend/utils/mb/wchar.c @@ -1,7 +1,10 @@ /* * conversion functions between pg_wchar and multi-byte streams. * Tatsuo Ishii - * $Id: wchar.c,v 1.8 1999/05/25 16:12:45 momjian Exp $ + * $Id: wchar.c,v 1.9 1999/07/11 22:47:20 ishii Exp $ + * + * WIN1250 client encoding updated by Pavel Behal + * */ #include "mb/pg_wchar.h" @@ -454,7 +457,8 @@ pg_wchar_tbl pg_wchar_table[] = { {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 30 */ {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 31 */ {0, pg_sjis_mblen}, /* 32 */ - {0, pg_big5_mblen} /* 33 */ + {0, pg_big5_mblen}, /* 33 */ + {pg_latin12wchar_with_len, pg_latin1_mblen} /* 34 */ }; /* returns the byte length of a word for mule internal code */ diff --git a/src/bin/psql/psqlHelp.h b/src/bin/psql/psqlHelp.h index f0789f553a16255b2214ecabcd36506dbbf742a7..63540a7998714c1a16411eb66cd9697439c44190 100644 --- a/src/bin/psql/psqlHelp.h +++ b/src/bin/psql/psqlHelp.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: psqlHelp.h,v 1.71 1999/06/17 15:15:51 momjian Exp $ + * $Id: psqlHelp.h,v 1.72 1999/07/11 22:47:21 ishii Exp $ * *------------------------------------------------------------------------- */ @@ -333,7 +333,7 @@ TIMEZONE|XACTISOLEVEL|CLIENT_ENCODING|SERVER_ENCODING"}, \tSET TRANSACTION ISOLATION LEVEL 'SERIALIZABLE'|'READ COMMITTED'\n\ \tSET CLIENT_ENCODING|NAMES TO 'EUC_JP'|'SJIS'|'EUC_CN'|'EUC_KR'|'EUC_TW'|\n\ \t 'BIG5'|'MULE_INTERNAL'|'LATIN1'|'LATIN2'|'LATIN3'|'LATIN4'|'LATIN5'|\n\ -\t 'KOI8|'WIN'|'ALT'\n\ +\t 'KOI8|'WIN'|'ALT'|'WIN1250'\n\ \tSET SERVER_ENCODING TO 'EUC_JP'|'SJIS'|'EUC_CN'|'EUC_KR'|'EUC_TW'|\n\ \t 'BIG5'|'MULE_INTERNAL'|'LATIN1'|'LATIN2'|'LATIN3'|'LATIN4'|'LATIN5'|\n\ \t 'KOI8|'WIN'|'ALT'"}, diff --git a/src/include/mb/pg_wchar.h b/src/include/mb/pg_wchar.h index 5e28b9a4f317b11331d6f91f384bd9508dded4a3..c007560f41e02e33d28c0bb1fe78d9e8d1bcd443 100644 --- a/src/include/mb/pg_wchar.h +++ b/src/include/mb/pg_wchar.h @@ -1,4 +1,4 @@ -/* $Id: pg_wchar.h,v 1.8 1999/05/25 16:14:04 momjian Exp $ */ +/* $Id: pg_wchar.h,v 1.9 1999/07/11 22:47:19 ishii Exp $ */ #ifndef PG_WCHAR_H #define PG_WCHAR_H @@ -29,6 +29,7 @@ /* followings are for client encoding only */ #define SJIS 32 /* Shift JIS */ #define BIG5 33 /* Big5 */ +#define WIN1250 34 /* windows-1250 */ #ifdef MULTIBYTE typedef unsigned int pg_wchar; @@ -79,7 +80,7 @@ typedef struct { int encoding; /* encoding symbol value */ char *name; /* encoding name */ - int is_client_only; /* 0: server/client bothg supported 1: + int is_client_only; /* 0: server/client both supported 1: * client only */ void (*to_mic) (); /* client encoding to MIC */ void (*from_mic) (); /* MIC to client encoding */