Re: setlocale not that ok...

"Craig A. Berry" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
On Jun 28, 2010, at 9:51 AM, Frediano Ziglio wrote:

> Hi,
>  I think that calling setlocale in a library with locale != NULL is
> mainly a bad idea. Doing setlocale change global settings that should
> be done by the application not by a library. Setting locale changes
> subtle things like sprintf witch application should be prepared to
> handle.
>
> I think we should remove setlocale(LC_ALL, "") in src/tds/mem.c and
> src/tds/locale.c. Applications like tsql, bsql and similars should
> call setlocale by themselves.

I think I understand the argument.  The counter-argument is that there  
is no other portoble way to interrogate the locale except by calling  
setlocale(LC_ALL, "").  The alternative to not calling it in the  
library is that any application that also does not call it will be  
getting the "C" locale, which means forcing US-ASCII as the client  
character set for any application that doesn't have its own  
setlocale(LC_ALL, "") call.

We can control what happens in src/apps, but my impression is that  
most people using FreeTDS are using language bindings or an ODBC  
driver manager and wouldn't know how to set the locale (or maybe  
wouldn't have a mechanism for doing so) even if they knew something a  
couple of layers down needed it.

Maybe we should give up on trying to get the local character set and  
just use ISO-8859-1 or UTF-8 unless explicitly overridden.  That might  
be less dreadful than having US-ASCII as the default.  I don't  
honestly know what the right thing to do is.

________________________________________
Craig A. Berry
mailto:[email protected]

"... getting out of a sonnet is much more
  difficult than getting in."
                  Brad Leithauser
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.