lua-users home
lua-l archive

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


> 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