Changed: #172 XML floating point serialization not using neutral culture (for VC++ 2005 and up)

This commit is contained in:
kervala 2014-08-02 11:18:24 +02:00
parent f63f7acfbd
commit 59b1141d37
2 changed files with 30 additions and 0 deletions

View file

@ -178,6 +178,9 @@ private:
// Error message
std::string _ErrorString;
// System dependant structure for locale
void* _Locale;
};

View file

@ -23,6 +23,11 @@
// Include from libxml2
#include <libxml/xmlerror.h>
#if defined(NL_OS_WINDOWS) && defined(NL_COMP_VC_VERSION) && NL_COMP_VC_VERSION >= 80
#define USE_LOCALE_SPRINTF
#include <locale.h>
#endif
using namespace std;
#ifdef DEBUG_NEW
@ -38,11 +43,22 @@ const char SEPARATOR = ' ';
// ***************************************************************************
#ifdef USE_LOCALE_SPRINTF
#define writenumber(src,format,digits) \
char number_as_cstring [digits+1]; \
_sprintf_l( number_as_cstring, format, (_locale_t)_Locale, src ); \
serialSeparatedBufferOut( number_as_cstring );
#else
#define writenumber(src,format,digits) \
char number_as_cstring [digits+1]; \
sprintf( number_as_cstring, format, src ); \
serialSeparatedBufferOut( number_as_cstring );
#endif
// ***************************************************************************
// XML callbacks
// ***************************************************************************
@ -133,6 +149,13 @@ COXml::COXml () : IStream (false /* Output mode */)
// Push begin
_PushBegin = false;
#ifdef USE_LOCALE_SPRINTF
// create C numeric locale
_Locale = _create_locale(LC_NUMERIC, "C");
#else
_Locale = NULL;
#endif
}
// ***************************************************************************
@ -192,6 +215,10 @@ COXml::~COXml ()
{
// Flush document to the internal stream
flush ();
#ifdef USE_LOCALE_SPRINTF
if (_Locale) _free_locale((_locale_t)_Locale);
#endif
}
// ***************************************************************************