views:

194

answers:

2

This function exists on OS X and allows you to pass custom local to the function. setlocale is not thread-safe, and passing locale as parameter is.

If there is no equivalent, any way of locale-independent printf, or printf just for doubles (%g) will be ok.

+3  A: 

You might try uselocale, which sets the thread locale (rather than the process locale) before calling printf.

Sunlight
Not perfect, but works. If anyone else has better answer, go ahead.
phjr
@Sunlight: I think you should amplify your answer a little - but I think you're probably right. @phjr: the BSD/MacOS X solution with printf_l() is arguably tidier, but the uselocale() should work.
Jonathan Leffler
A: 

There are locale-independent double to string convertion routines at http://www.netlib.org/fp/. String to double conversion is available too. The API is not very nice, but the code works.

phjr