]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/intl.cpp
0 -> 0u to keep gcc happy
[wxWidgets.git] / src / common / intl.cpp
index e7103825e02656ee576ecbca72140e15e5458e8d..97f504628169f587071ec06fed3ed002a82d5e4f 100644 (file)
     #pragma implementation "intl.h"
 #endif
 
+#if defined(__BORLAND__) && !defined(__WXDEBUG__)
+    // There's a bug in Borland's compiler that breaks wxLocale with -O2,
+    // so make sure that flag is not used for this file:
+    #pragma option -O1
+#endif
+
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -1215,7 +1221,7 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash, bool convertEncoding) cons
     if ( convertEncoding )
     {
         wxFontEncoding targetEnc = wxFONTENCODING_SYSTEM;
-        wxFontEncoding enc = wxFontMapper::Get()->CharsetToEncoding(charset, FALSE);
+        wxFontEncoding enc = wxFontMapper::Get()->CharsetToEncoding(m_charset, FALSE);
         if ( enc == wxFONTENCODING_SYSTEM )
         {
             convertEncoding = FALSE; // unknown encoding
@@ -2238,6 +2244,14 @@ wxFontEncoding wxLocale::GetSystemEncoding()
     {
         return wxFONTENCODING_CP950;
     }
+#elif defined(__WXMAC__)
+       TextEncoding encoding = 0 ;
+#if TARGET_CARBON
+       encoding = CFStringGetSystemEncoding() ;
+#else
+        UpgradeScriptInfoToTextEncoding ( smSystemScript , kTextLanguageDontCare , kTextRegionDontCare , NULL , &encoding ) ;
+#endif
+    return wxMacGetFontEncFromSystemEnc( encoding ) ;
 #elif defined(__UNIX_LIKE__) && wxUSE_FONTMAP
     wxString encname = GetSystemEncodingName();
     if ( !encname.empty() )
@@ -2420,15 +2434,16 @@ const wxChar *wxLocale::GetString(const wxChar *szOrigString,
             if ( szDomain != NULL )
             {
                 wxLogTrace(_T("i18n"),
-                           _T("string '%s'[%ld] not found in domain '%s' for locale '%s'."),
-                           szOrigString, n, szDomain, m_strLocale.c_str());
+                           _T("string '%s'[%lu] not found in domain '%s' for locale '%s'."),
+                           szOrigString, (unsigned long)n,
+                           szDomain, m_strLocale.c_str());
 
             }
             else
             {
                 wxLogTrace(_T("i18n"),
-                           _T("string '%s'[%ld] not found in locale '%s'."),
-                           szOrigString, n, m_strLocale.c_str());
+                           _T("string '%s'[%lu] not found in locale '%s'."),
+                           szOrigString, (unsigned long)n, m_strLocale.c_str());
             }
         }
 #endif // __WXDEBUG__
@@ -2492,12 +2507,10 @@ bool wxLocale::AddCatalog(const wxChar *szDomain)
 // accessors for locale-dependent data
 // ----------------------------------------------------------------------------
 
-#if 0
-
 #ifdef __WXMSW__
 
 /* static */
-wxString wxLocale::GetInfo(wxLocaleInfo index)
+wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat)
 {
     wxString str;
     wxChar buffer[256];
@@ -2505,13 +2518,14 @@ wxString wxLocale::GetInfo(wxLocaleInfo index)
     buffer[0] = wxT('\0');
     switch (index)
     {
-        case wxSYS_DECIMAL_SEPARATOR:
+        case wxLOCALE_DECIMAL_POINT:
             count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buffer, 256);
             if (!count)
                 str << ".";
             else
                 str << buffer;
             break;
+#if 0
         case wxSYS_LIST_SEPARATOR:
             count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLIST, buffer, 256);
             if (!count)
@@ -2526,6 +2540,7 @@ wxString wxLocale::GetInfo(wxLocaleInfo index)
             else
                 str << buffer;
             break;
+#endif
         default:
             wxFAIL_MSG("Unknown System String !");
     }
@@ -2535,15 +2550,38 @@ wxString wxLocale::GetInfo(wxLocaleInfo index)
 #else // !__WXMSW__
 
 /* static */
-wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory)
+wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat)
 {
-    return wxEmptyString;
-}
+    struct lconv *locale_info = localeconv();
+    switch (cat)
+    {
+        case wxLOCALE_CAT_NUMBER:
+            switch (index)
+            {
+                case wxLOCALE_THOUSANDS_SEP:
+                    return locale_info->thousands_sep;
+                case wxLOCALE_DECIMAL_POINT:
+                    return locale_info->decimal_point;
+                default:
+                    return wxEmptyString;
+            }
+        case wxLOCALE_CAT_MONEY:
+            switch (index)
+            {
+                case wxLOCALE_THOUSANDS_SEP:
+                    return locale_info->mon_thousands_sep;
+                case wxLOCALE_DECIMAL_POINT:
+                    return locale_info->mon_decimal_point;
+                default:
+                    return wxEmptyString;
+            }
+        default:
+            return wxEmptyString;
+    }
+}      
 
 #endif // __WXMSW__/!__WXMSW__
 
-#endif // 0
-
 // ----------------------------------------------------------------------------
 // global functions and variables
 // ----------------------------------------------------------------------------