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

hg/feature/cdb-packed
kervala 10 years ago
parent b71ec9e7d4
commit 7aedffce9a

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

@ -23,6 +23,11 @@
// Include from libxml2 // Include from libxml2
#include <libxml/xmlerror.h> #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; using namespace std;
#ifdef DEBUG_NEW #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) \ #define writenumber(src,format,digits) \
char number_as_cstring [digits+1]; \ char number_as_cstring [digits+1]; \
sprintf( number_as_cstring, format, src ); \ sprintf( number_as_cstring, format, src ); \
serialSeparatedBufferOut( number_as_cstring ); serialSeparatedBufferOut( number_as_cstring );
#endif
// *************************************************************************** // ***************************************************************************
// XML callbacks // XML callbacks
// *************************************************************************** // ***************************************************************************
@ -133,6 +149,13 @@ COXml::COXml () : IStream (false /* Output mode */)
// Push begin // Push begin
_PushBegin = false; _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 document to the internal stream
flush (); flush ();
#ifdef USE_LOCALE_SPRINTF
if (_Locale) _free_locale((_locale_t)_Locale);
#endif
} }
// *************************************************************************** // ***************************************************************************

Loading…
Cancel
Save