Jakob Lund wrote:
> There's a solution here, but it's a bit ugly... using the strtod_l conversion 
> function, and keeping a "C" locale object around for the purpose of passing 
> to that function _works_, but it seems a bit hacky.

Is strtod_l() an ANSI, portable member of the C standard library?  I can't find 
that it is... but it seems to be.

WORKAROUND FOR THE PROBLEM:

   $ LC_NUMERIC=C ./hydrogen

For the permanent solution, here are some of the options I know of:

1. Reinstate the old Object.h functions, which use C++
    streams to do the string conversions.  The ISO C++
    standard requires that these use the "C" locale by
    default (unless the imbue() function changes it).
    PROS:  Stable, lots of history with Hydrogen.
           Endorsed by KF.  :-)
    CONS:  I'm not a big fan of the QString-->std::string
           -->std::istringstream-->double process of
           converting the string.

2. Adjust QLocale while reading/writing XML files.  However,
    QLocale::setCurrent() is not considered thread-safe... and
    it may change the locale for the whole application while
    loading the XML file.
    PROS:  Consistently uses QString methods.
    CONS:  I don't think it will work.

3. Use strtod_l().
    PROS:  Allows us to set the locale explicitly.
    CONS:  Not sure if it's ANSI.
           Converts QString to 8-bit string to do
           the conversion.

4. Write our own string-to-decimal conversion.  (This is
    the solution employed by glib/GTK when they encountered
    the same problem.  viz. g_ascii_strtod(), which always
    uses the "C" locale.)
    PROS:  Will work, and gives us lots of flexability.
    CONS:  We have to program and debug it.
           Copying g_ascii_strtod() may present licensing
           issues.

5. Use glib's g_ascii_strtod().
    PROS:  Already programmed.
           It already links to glib on my PC.
    CONS:  Increases library dependencies.
           I don't think we actually use 'glib', and the
           library linkage isn't needed.

Comments?  Suggestions?

Thanks,
Gabriel

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have 
the opportunity to enter the BlackBerry Developer Challenge. See full prize 
details at: http://p.sf.net/sfu/blackberry
_______________________________________________
Hydrogen-devel mailing list
Hydrogen-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hydrogen-devel

Reply via email to