[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature request: c-snprintf
From: |
Bruno Haible |
Subject: |
Re: Feature request: c-snprintf |
Date: |
Tue, 24 Mar 2009 23:18:12 +0100 |
User-agent: |
KMail/1.9.9 |
Eric Blake wrote:
> Huh? ... John is asking for converting numbers to strings
Yes. Ooooops, what I wrote was complete nonsense.
So, for numbers to strings, there are four ways to proceed:
1) Use the snprintf_l function available on MacOS X 10.5.
Drawback: Unportable, and gnulib cannot provide an easy replacement for
locale_t on other systems.
2) Switch the locale to "C" temporarily for the duration of the conversion.
Like done in gnulib/lib/c-strtod.c.
Drawbacks: Will be slow on many systems. Not multi-thread safe.
3) Split the format string into individual format directives, and for those
that convert numbers, call the snprintf function for the current locale,
change decimal_point_char() occurrences to '.', and remove grouping
characters.
Drawback: Some code to write yourself.
4) Use code extracted from gnulib/lib/vasnprintf.c, modified to use '.'
instead of decimal_point_char().
Drawback: Code duplicatiion.
Opinions?
Bruno