Hi,tom lane

> No, it would most certainly be inappropriate for a library to do that.
> setlocale could completely break a program that wasn't expecting it.
> The effects would be global across the whole process, not confined to
> the library.

First,does you agree with the need of native language support without writing
"setlocale(LC_ALL, "")"in user's program is rational?
If the answer is yes, let see if there is a mothod to solve it.
Simply write "setlocale(LC_ALL, "")" in libpq and ecpglib may cause other
problems as you said. But how about only call setlocale() before call 
dgettext(),
and soon restore to the original value after called.

*)Excuse me for my English.

for example:
libpq_gettext(const char *msgid):
=====================================================
return dgettext(PG_TEXTDOMAIN("libpq"), msgid);

==>
char *result;
if(strcmp(setlocale(LC_MESSAGES,NULL),"C")==0)
{
        setlocale(LC_MESSAGES, "");
        result = dgettext(PG_TEXTDOMAIN("libpq"), msgid);
        setlocale(LC_MESSAGES, "C");
}else
{
        result = dgettext(PG_TEXTDOMAIN("libpq"), msgid);
}
return result;
=====================================================

(2012/11/16 13:22), Tom Lane wrote:
> che...@cn.fujitsu.com writes:
>> I knows reason. The default locale of a program is "C" in Linux,regardless
>> the Environment Variables.
>> if add the following line in my program,everything is OK.
> 
>> setlocale(LC_ALL, "");
> 
>> But I found no document tell users should do so.And I think it's not a easy
>> way.Can libpq and ecpglib do it for users?
> 
> No, it would most certainly be inappropriate for a library to do that.
> setlocale could completely break a program that wasn't expecting it.
> The effects would be global across the whole process, not confined to
> the library.
> 
>                       regards, tom lane
> 
> 

-- 
Best Regards,
chen hujuan



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to