Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get equivalent of printf_l on Linux?

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.

like image 456
Paweł Hajdan Avatar asked Oct 15 '22 18:10

Paweł Hajdan


2 Answers

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

like image 189
Sunlight Avatar answered Oct 18 '22 10:10

Sunlight


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.

like image 40
Paweł Hajdan Avatar answered Oct 18 '22 11:10

Paweł Hajdan