Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

more setlocale fun


  • From: Andrew Dunstan <andrew(at)dunslane(dot)net>
  • To: pgsql-hackers-win32 <pgsql-hackers-win32(at)postgresql(dot)org>
  • Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>
  • Subject: more setlocale fun
  • Date: Fri, 10 Oct 2003 10:31:32 -0400
  • Message-id: <3F86C2C4.7020209@dunslane.net> <text/plain>


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




Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group