diff --git a/code/nel/include/nel/misc/i_xml.h b/code/nel/include/nel/misc/i_xml.h index a9452e341..cf2527e21 100644 --- a/code/nel/include/nel/misc/i_xml.h +++ b/code/nel/include/nel/misc/i_xml.h @@ -232,6 +232,9 @@ private: // If not NULL, binary mode detected, use this stream in serials IStream *_BinaryStream; + + // System dependant structure for locale + void* _Locale; }; diff --git a/code/nel/src/misc/i_xml.cpp b/code/nel/src/misc/i_xml.cpp index d8925ddef..3b7f0f9e2 100644 --- a/code/nel/src/misc/i_xml.cpp +++ b/code/nel/src/misc/i_xml.cpp @@ -24,6 +24,11 @@ // Include from libxml2 #include +#if defined(NL_OS_WINDOWS) && defined(NL_COMP_VC_VERSION) && NL_COMP_VC_VERSION >= 80 +#define USE_LOCALE_ATOF +#include +#endif + using namespace std; #define NLMISC_READ_BUFFER_SIZE 1024 @@ -46,6 +51,22 @@ const char SEPARATOR = ' '; serialSeparatedBufferIn( number_as_string ); \ dest = (thetype)convfunc( number_as_string.c_str() ); +#ifdef USE_LOCALE_ATOF + +#define readnumberlocale(dest,thetype,digits,convfunc) \ + string number_as_string; \ + serialSeparatedBufferIn( number_as_string ); \ + dest = (thetype)convfunc( number_as_string.c_str(), (_locale_t)_Locale ); + +#define nl_atof _atof_l + +#else + +#define readnumberlocale(dest,thetype,digits,convfunc) readnumber(dest,thetype,digits,convfunc) +#define nl_atof atof + +#endif + // *************************************************************************** inline void CIXml::flushContentString () @@ -70,6 +91,13 @@ CIXml::CIXml () : IStream (true /* Input mode */) _ErrorString = ""; _TryBinaryMode = false; _BinaryStream = NULL; + +#ifdef USE_LOCALE_ATOF + // create C numeric locale + _Locale = _create_locale(LC_NUMERIC, "C"); +#else + _Locale = NULL; +#endif } // *************************************************************************** @@ -85,6 +113,13 @@ CIXml::CIXml (bool tryBinaryMode) : IStream (true /* Input mode */) _ErrorString = ""; _TryBinaryMode = tryBinaryMode; _BinaryStream = NULL; + +#ifdef USE_LOCALE_ATOF + // create C numeric locale + _Locale = _create_locale(LC_NUMERIC, "C"); +#else + _Locale = NULL; +#endif } // *************************************************************************** @@ -119,6 +154,10 @@ void CIXml::release () _ErrorString = ""; resetPtrTable(); + +#ifdef USE_LOCALE_ATOF + if (_Locale) _free_locale((_locale_t)_Locale); +#endif } // *************************************************************************** @@ -546,7 +585,7 @@ void CIXml::serial(float &b) } else { - readnumber( b, float, 128, atof ); + readnumberlocale( b, float, 128, nl_atof ); } } @@ -560,7 +599,7 @@ void CIXml::serial(double &b) } else { - readnumber( b, double, 128, atof ); + readnumberlocale( b, double, 128, nl_atof ); } }