*** mbutils.c.orig Sun Nov 23 08:42:57 2008 --- mbutils.c Wed Nov 26 12:17:12 2008 *************** *** 822,830 **** --- 822,870 ---- return clen; } + #ifdef WIN32 + static const struct codeset_map { + int encoding; + const char *codeset; + } codeset_map_array[] = { + {PG_UTF8, "UTF-8"}, + {PG_LATIN1, "LATIN1"}, + {PG_LATIN2, "LATIN2"}, + {PG_LATIN3, "LATIN3"}, + {PG_LATIN4, "LATIN4"}, + {PG_ISO_8859_5, "ISO-8859-5"}, + {PG_ISO_8859_6, "ISO_8859-6"}, + {PG_ISO_8859_7, "ISO-8859-7"}, + {PG_ISO_8859_8, "ISO-8859-8"}, + {PG_LATIN5, "LATIN5"}, + {PG_LATIN6, "LATIN6"}, + {PG_LATIN7, "LATIN7"}, + {PG_LATIN8, "LATIN8"}, + {PG_LATIN9, "LATIN-9"}, + {PG_LATIN10, "LATIN10"}, + {PG_KOI8R, "KOI8-R"}, + {PG_WIN1250, "CP1250"}, + {PG_WIN1251, "CP1251"}, + {PG_WIN1252, "CP1252"}, + {PG_WIN1253, "CP1253"}, + {PG_WIN1254, "CP1254"}, + {PG_WIN1255, "CP1255"}, + {PG_WIN1256, "CP1256"}, + {PG_WIN1257, "CP1257"}, + {PG_WIN1258, "CP1258"}, + {PG_WIN866, "CP866"}, + {PG_WIN874, "CP874"}, + {PG_EUC_CN, "EUC-CN"}, + {PG_EUC_JP, "EUC-JP"}, + {PG_EUC_KR, "EUC-KR"}, + {PG_EUC_TW, "EUC-TW"}}; + #endif /* WIN32 */ + void SetDatabaseEncoding(int encoding) { + const char *target_codeset = NULL; + if (!PG_VALID_BE_ENCODING(encoding)) elog(ERROR, "invalid database encoding: %d", encoding); *************** *** 846,852 **** */ #ifdef ENABLE_NLS if (encoding == PG_UTF8) ! if (bind_textdomain_codeset("postgres", "UTF-8") == NULL) elog(LOG, "bind_textdomain_codeset failed"); #endif } --- 886,907 ---- */ #ifdef ENABLE_NLS if (encoding == PG_UTF8) ! target_codeset = "UTF-8"; ! #ifdef WIN32 ! else ! { ! int i; ! ! for (i = 0; i < sizeof(codeset_map_array) / sizeof(struct codeset_map); i++) ! if (codeset_map_array[i].encoding == encoding) ! { ! target_codeset = codeset_map_array[i].codeset; ! break; ! } ! } ! #endif /* WIN32 */ ! if (target_codeset != NULL) ! if (bind_textdomain_codeset("postgres", target_codeset) == NULL) elog(LOG, "bind_textdomain_codeset failed"); #endif }