backend/main/main.c contains this code:
/*
* Set up locale information from environment. Note that LC_CTYPE and
* LC_COLLATE will be overridden later from pg_control if we are in an
* already-initialized database. We set them here so that they will
* be available to fill pg_control during initdb. LC_MESSAGES will get
* set later during GUC option processing, but we set it here to allow
* startup error messages to be localized.
*/
setlocale(LC_COLLATE, "");
setlocale(LC_CTYPE, "");
#ifdef LC_MESSAGES
setlocale(LC_MESSAGES, "");
#endif
Unfortunately, on Windows this won't have the desired effect, as
setlocale(category,"") apparently does not read from the environment,
which we will have been careful to set up in initdb - it reads from the
current codepage settings, it seems.
On Windows we'll have to do something like this, I think:
char * loc;
if ((loc = getenv("LC_CTYPE") != NULL)
setlocale(LC_CTYPE,loc);
else
setlocale(LC_CTYPE,"");
...
(cygwin behaves "correctly", though)
cheers
andrew