From c3b5d2f1383bb96a52dcc75dedca02ad42fc7850 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Sun, 8 Mar 2009 16:07:12 +0000 Subject: On Windows, call bind_textdomain_codeset on domains other than the default one, too, so that the codeset is properly mapped on the newly added PL domains. --- src/backend/utils/mb/mbutils.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'src/backend/utils/mb/mbutils.c') diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c index f5ba80d101d..cf6e5d0824f 100644 --- a/src/backend/utils/mb/mbutils.c +++ b/src/backend/utils/mb/mbutils.c @@ -4,7 +4,7 @@ * (currently mule internal code (mic) is used) * Tatsuo Ishii * - * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.79 2009/03/02 15:10:09 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.80 2009/03/08 16:07:12 alvherre Exp $ */ #include "postgres.h" @@ -891,22 +891,27 @@ SetDatabaseEncoding(int encoding) DatabaseEncoding = &pg_enc2name_tbl[encoding]; Assert(DatabaseEncoding->encoding == encoding); - /* - * On Windows, we need to explicitly bind gettext to the correct - * encoding, because gettext() tends to get confused. - */ + pg_bind_textdomain_codeset(textdomain(NULL), encoding); +} + +/* + * On Windows, we need to explicitly bind gettext to the correct + * encoding, because gettext() tends to get confused. + */ +void +pg_bind_textdomain_codeset(const char *domainname, int encoding) +{ #if defined(ENABLE_NLS) && defined(WIN32) - { - int i; + int i; - for (i = 0; i < sizeof(codeset_map_array) / sizeof(codeset_map_array[0]); i++) + for (i = 0; i < lengthof(codeset_map_array); i++) + { + if (codeset_map_array[i].encoding == encoding) { - if (codeset_map_array[i].encoding == encoding) - { - if (bind_textdomain_codeset(textdomain(NULL), codeset_map_array[i].codeset) == NULL) - elog(LOG, "bind_textdomain_codeset failed"); - break; - } + if (bind_textdomain_codeset(domainname, + codeset_map_array[i].codeset) == NULL) + elog(LOG, "bind_textdomain_codeset failed"); + break; } } #endif -- cgit v1.2.3