GNOME Bugzilla – Bug 150200
gst_init breaks atof, strtod etc.
Last modified: 2004-12-22 21:47:04 UTC
Seems like gstreamer a some strange side effect on libc's atof() function: #include <gst/gst.h> #include <stdlib.h> int main (int argc, char **argv) { printf("f=%f\n", atof("0.22")); gst_init(&argc, &argv); printf("f=%f\n", atof("0.22")); return 0; } outputs: f=0.220000 f=0,000000
We set locale information and so on. I think atof() will, after the call to gst_init(), expect commas rather than dots. Solution is to set the locale before doing any other function calls.
Thanks, that helps. But is it still a bug!? I would expect a media library (any library) to respect my locale setting, but not to change it... But perhaps I am wrong, I justed checked ant saw that gtk_init() does the same thing. Problem is (ok not really a problem) my gstreamer based app uses libxml2 to read/write configuration data, and libxml2 writes "0.2" to the file, so it seems to ignore the locale set by gtk or gst.
In that case, you're apparently using libxml2 for parsing the file during writing, but doing the reading yourself. Either do both yourself or have libxml2 do both. We're supposed to change such settings inside the application, because otherwise i18n in plugins doesn't work...
Nono, of course I am doing reading and writing with libxml (libxml++ do be exact). But libxml++ does only take strings as attribute values. Now i am using g_sprintf for writing the float, which respects the locale and i am pleased:-)
Actually, you need functions that _ignore_ the locale setting, and are thus locale-independent. See g_ascii_strtod() and friends.
reporter seems to be happy with resolution that it is in fact not a bug. closing.