+#if !wxUSE_STD_STRING
+ #include <locale.h> // for setlocale and LC_ALL
+#endif
+
+// ----------------------------------------------------------------------------
+// local helpers
+// ----------------------------------------------------------------------------
+
+namespace
+{
+
+// Contains information about the locale which was used to initialize our
+// cached values of the decimal and thousands separators. Notice that it isn't
+// enough to store just wxLocale because the user code may call setlocale()
+// directly and storing just C locale string is not enough because we can use
+// the OS API directly instead of the CRT ones on some platforms. So just store
+// both.
+class LocaleId
+{
+public:
+ LocaleId()
+ {
+#if wxUSE_INTL
+ m_wxloc = NULL;
+#endif // wxUSE_INTL
+ m_cloc = NULL;
+ }
+
+ ~LocaleId()
+ {
+ Free();
+ }
+
+#if wxUSE_INTL
+ // Return true if this is the first time this function is called for this
+ // object or if the program locale has changed since the last time it was
+ // called. Otherwise just return false indicating that updating locale-
+ // dependent information is not necessary.
+ bool NotInitializedOrHasChanged()
+ {
+ wxLocale * const wxloc = wxGetLocale();
+ const char * const cloc = setlocale(LC_ALL, NULL);
+ if ( m_wxloc || m_cloc )
+ {
+ if ( m_wxloc == wxloc && strcmp(m_cloc, cloc) == 0 )
+ return false;
+
+ Free();
+ }
+ //else: Not initialized yet.
+
+ m_wxloc = wxloc;
+ m_cloc = wxCRT_StrdupA(cloc);
+
+ return true;
+ }
+#endif // wxUSE_INTL
+
+private:
+ void Free()
+ {
+#if wxUSE_INTL
+ free(m_cloc);
+#endif // wxUSE_INTL
+ }
+
+#if wxUSE_INTL
+ // Non-owned pointer to wxLocale which was used.
+ wxLocale *m_wxloc;
+#endif // wxUSE_INTL
+
+ // Owned pointer to the C locale string.
+ char *m_cloc;
+
+ wxDECLARE_NO_COPY_CLASS(LocaleId);
+};
+
+} // anonymous namespace
+