]> git.sesse.net Git - vlc/blobdiff - src/text/charset.c
Add a us_strtof function to prevent some problem
[vlc] / src / text / charset.c
index 6d4d2a7b4030f64b3d1c249cde0c29144c99babc..7812cb917edf046c0f8e15e6bdbd659ed7d189f7 100644 (file)
@@ -91,6 +91,26 @@ double us_strtod( const char *str, char **end )
     return res;
 }
 
+
+/**
+ * us_strtof() has the same prototype as ANSI C strtof() but it uses the
+ * POSIX/C decimal format, regardless of the current numeric locale.
+ */
+float us_strtof( const char *str, char **end )
+{
+    locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
+    locale_t oldloc = uselocale (loc);
+    float res = strtof (str, end);
+
+    if (loc != (locale_t)0)
+    {
+        uselocale (oldloc);
+        freelocale (loc);
+    }
+    return res;
+}
+
+
 /**
  * us_atof() has the same prototype as ANSI C atof() but it expects a dot
  * as decimal separator, regardless of the system locale.