1

Darwin and BSD have the printf_l/sprintf_l/vsprintf_l, etc., family of formatted output functions that include an explicit locale (which can be set to the "C" locale to force locale-independent output, such as you would require for portable text output files containing floating point values).

Windows also has the equivalent (same names but preceded by an underscore).

But I can't seem to find the equivalent for Linux/glibc. Is there an alternative? What is the equivalent or preferred way to generate locale-independent formatted output on Linux?

Larry Gritz
  • 13,331
  • 5
  • 42
  • 42
  • https://stackoverflow.com/questions/272479/how-to-get-equivalent-of-printf-l-on-linux –  Nov 18 '19 at 01:19
  • @Readowl, Thanks for the reference, but that question unfortunately doesn't give the answer and the OP settles for a pointer to a function that just converts a single floating-point number rather than a full implementation of formatted output a la sprintf. – Larry Gritz Nov 18 '19 at 07:15
  • Does this answer your question? [How to get equivalent of printf\_l on Linux?](https://stackoverflow.com/questions/272479/how-to-get-equivalent-of-printf-l-on-linux) – malat May 03 '22 at 08:43

1 Answers1

0

Aha, there is a public domain (or dual MIT licensed) sprintf family of functions available from https://github.com/nothings/stb

Technically, this isn't truly equivalent to print_l because you can't explicitly set an arbitrary locale. But it is hard coded to be like the "C" locale, which turns out to be the behavior I was after all along.

Larry Gritz
  • 13,331
  • 5
  • 42
  • 42