Re: setlocale

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Postgresql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: setlocale
Date: 2003-10-08 17:38:30
Message-ID: Pine.LNX.4.44.0310081929570.26413-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-hackers-win32

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(at)gmx(dot)net

In response to

  • setlocale at 2003-10-08 16:56:24 from Andrew Dunstan

Browse pgsql-hackers by date

  From Date Subject
Next Message Neil Conway 2003-10-08 17:38:53 confused about bit strings
Previous Message Bruce Momjian 2003-10-08 17:28:53 Re: PostgreSQL vs. MySQL

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Bruce Momjian 2003-10-10 00:31:49 Re: lib problems
Previous Message Andrew Dunstan 2003-10-08 16:56:24 setlocale