[cairo] float-to-string conversion vs locale

Alexander Larsson alexl at redhat.com
Sat Apr 29 02:03:23 PDT 2006


I just took a look at the float-to-string conversions in the postscript
backend:

_cairo_output_stream_printf (output_stream,
			 "%f %f moveto ",
			 _cairo_fixed_to_double (point->x),
			 _cairo_fixed_to_double (point->y));

This is not locale-safe. In a locale with a decimal separator other than
"." it will not produce valid postscript. Changing the locale to "C"
while doing this is instead not threadsafe.

For an approach to do this in a thread-safe way (the only good way I
know of) see g_ascii_formatd() in glib (glib/gstrfuncs.c).

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl at redhat.com    alla at lysator.liu.se 
He's a short-sighted one-eyed waffle chef with acid for blood. She's a 
manipulative out-of-work museum curator from beyond the grave. They fight 
crime! 



More information about the cairo mailing list