lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


You can still use setlocale on Windows, as long as you do
_configurethreadlocale(_ENABLE_PER_THREAD_LOCALE) first:

http://msdn.microsoft.com/en-us/library/26c0tb7x(v=vs.80).aspx

--
Fabio


On Wed, Jun 22, 2011 at 2:52 PM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> I think there's no easy way. On posix systems you can use newlocale /
>> uselocale / freelocale to change it per-thread [1]
>> On Windows you have SetThreadLocale [2]. So, changing locale in a thread
>> safe way is not portable. Some #ifdefs will be needed.
>
> On Posix, it seems that the following does the trick:
>
>  /* get current locale */
>  oldloc = uselocale((locale_t)0);
>
>  /* set new locale */
>  loc = newlocale(LC_ALL_MASK, "C", NULL);
>  uselocale(loc);
>  freelocale(loc);
>
>  /* restore previous locale */
>  uselocale(oldloc);
>
>
> For Windows, I could not figure out how to set a "C" locale with its
> "SetThreadLocale"...
>
> -- Roberto
>
>