The MS runtime docs on setlocale() contaiun the following statement:

  At program startup, the equivalent of the following statement is executed:

  setlocale( LC_ALL, "C" );

Does this have any effect on us? Does it mean, as it appears to, that the locale will not be inherited from the parent? 

If so, I guess it could be got around by passing LC_COLLATE and LC_CTYPE arguments to postgres when running the bootstrap code. 

Of course, if I'm right, initdb would not pick up the locale from its caller, which might be ugly if that was what you expected.

(I'm new to this locale stuff - I know we have some experts out there).

Another question - will we want to internationalize initdb (I'm new to that, too :-) )

cheers

andrew



Wed, 08 Oct 2003 12:56:24 -0400
Andrew Dunstan <andrew@dunslane.net>
setlocale
Andrew Dunstan writes:

>   At program startup, the equivalent of the following statement is executed:
>   setlocale( LC_ALL, "C" );
> Does this have any effect on us?

No, that is just a peculiar way to express that by default nothing
happens.

> Does it mean, as it appears to, that the locale will not be inherited
> from the parent?

A process never inherits the locale from the parent.  It only inherits
environment variables, among which may be LC_ALL, etc.  To activate any
kind of locale in a program you need to call

setlocale(LC_xxx, "something");

where "something" may be the name of the actual locale you want, or -- as
a special case -- it may be "", in which case it takes the value of the
respective environment variable LC_xxx.

There is an appearance of inheritance in shell scripts, but only because
the shell takes care of some of these things automatically.

> If so, I guess it could be got around by passing LC_COLLATE and LC_CTYPE
> arguments to postgres when running the bootstrap code.

The easiest solution would be to stick LC_COLLATE and LC_CTYPE into the
environment of the postgres process when you call it the first time (in
bootstrap mode).  If no --lc-* options were given, you don't need to do
anything, because "postgres" will just take what's in the environment.  If
--lc-* options where given, you could use putenv().

> Another question - will we want to internationalize initdb

Yes, but that should really wait until we have a working C version first.

-- 
Peter Eisentraut   peter_e@gmx.net


Wed, 8 Oct 2003 19:38:30 +0200 (CEST)
Peter Eisentraut <peter_e@gmx.net>
Re: setlocale