if ( m_strShort.IsEmpty() ) {
// FIXME I don't know how these 2 letter abbreviations are formed,
// this wild guess is surely wrong
- m_strShort = tolower(szLocale[0]) + tolower(szLocale[1]);
+ if ( szLocale[0] )
+ {
+ m_strShort += (wxChar)wxTolower(szLocale[0]);
+ if ( szLocale[1] )
+ m_strShort += (wxChar)wxTolower(szLocale[1]);
+ }
}
// save the old locale to be able to restore it later
return wxLANGUAGE_ENGLISH;
}
- if ( langFull == _T("C") )
+ if ( langFull == _T("C") || langFull == _T("POSIX") )
{
// default C locale
return wxLANGUAGE_ENGLISH;
// the language string has the following form
//
- // lang[_LANG[.encoding]]
+ // lang[_LANG][.encoding][@modifier]
+ //
+ // (see environ(5) in the Open Unix specification)
//
- // where lang is the primary language, LANG is a sublang
+ // where lang is the primary language, LANG is a sublang/territory,
+ // encoding is the charset to use and modifier "allows the user to select
+ // a specific instance of localization data within a single category"
//
// for example, the following strings are valid:
// fr
// fr_FR
// de_DE.iso88591
+ // de_DE@euro
+ // de_DE.iso88591@euro
// for now we don't use the encoding, although we probably should (doing
// translations of the msg catalogs on the fly as required) (TODO)
- langFull = langFull.BeforeFirst(_T('.'));
+ //
+ // we don't use the modifiers neither but we probably should translate
+ // "euro" into iso885915
+ size_t posEndLang = langFull.find_first_of(_T("@."));
+ if ( posEndLang != wxString::npos )
+ {
+ langFull.Truncate(posEndLang);
+ }
// in addition to the format above, we also can have full language names
// in LANG env var - for example, SuSE is known to use LANG="german" - so
{
wxString encname;
-#ifdef __WIN32__
+#if defined(__WIN32__) && !defined(__WXMICROWIN__)
// FIXME: what is the error return value for GetACP()?
UINT codepage = ::GetACP();
encname.Printf(_T("windows-%u"), codepage);
/* static */
wxFontEncoding wxLocale::GetSystemEncoding()
{
-#ifdef __WIN32__
+#if defined(__WIN32__) && !defined(__WXMICROWIN__)
UINT codepage = ::GetACP();
- // wxWindows only knows about CP1250-1257
+ // wxWindows only knows about CP1250-1257, 932, 936, 949, 950
if ( codepage >= 1250 && codepage <= 1257 )
{
return (wxFontEncoding)(wxFONTENCODING_CP1250 + codepage - 1250);
}
+
+ if ( codepage == 932 )
+ {
+ return wxFONTENCODING_CP932;
+ }
+
+ if ( codepage == 936 )
+ {
+ return wxFONTENCODING_CP936;
+ }
+
+ if ( codepage == 949 )
+ {
+ return wxFONTENCODING_CP949;
+ }
+
+ if ( codepage == 950 )
+ {
+ return wxFONTENCODING_CP950;
+ }
#elif defined(__UNIX_LIKE__) && wxUSE_FONTMAP
wxString encname = GetSystemEncodingName();
if ( !encname.empty() )
return (wxMB2WXbuf)(szOrigString);
}
- else
- {
- return wxConvertMB2WX(pszTrans); // or preferably wxCSConv(charset).cMB2WX(pszTrans) or something,
- // a macro similar to wxConvertMB2WX could be written for that
- }
+ // or preferably wxCSConv(charset).cMB2WX(pszTrans) or something, a macro
+ // similar to wxConvertMB2WX could be written for that
+
+ return wxConvertMB2WX(pszTrans);
+
+ // undo the hack from the beginning of this function
#undef szOrgString
}