On Tue, Mar 24, 2009 at 11:18:12PM +0100, Bruno Haible wrote:
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?
I would have thought option 4 was the best way. Code duplication
could be minimised by refactoring and wrapping the existing vasnprintf
in a function which calls decimal_point_char and the new one uses '.'
J'-- PGP Public key ID: 1024D/2DE827B3 fingerprint = 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3 See http://pgp.mit.edu or any PGP keyserver for public key.
signature.asc
Description: Digital signature
