static const size_t LEN_SUBLANG = 2;
static const size_t LEN_FULL = LEN_LANG + 1 + LEN_SUBLANG; // 1 for '_'
-#define TRACE_I18N _T("i18n")
+#define TRACE_I18N wxS("i18n")
// ----------------------------------------------------------------------------
// global functions
#ifdef __UNIX__
// LC_PATH is a standard env var containing the search path for the .mo
// files
- const wxChar *pszLcPath = wxGetenv(wxT("LC_PATH"));
+ const char *pszLcPath = wxGetenv("LC_PATH");
if ( pszLcPath )
{
const wxString lcp = GetMsgCatalogSubdirs(pszLcPath, lang);
wxString wxp = wxGetInstallPrefix();
if ( !wxp.empty() )
{
- wxp = GetMsgCatalogSubdirs(wxp + _T("/share/locale"), lang);
+ wxp = GetMsgCatalogSubdirs(wxp + wxS("/share/locale"), lang);
if ( paths.Index(wxp) == wxNOT_FOUND )
paths.Add(wxp);
}
if ( encSys != wxFONTENCODING_SYSTEM )
{
wxString fullname(szDirPrefix);
- fullname << _T('.') << wxFontMapperBase::GetEncodingName(encSys);
+ fullname << wxS('.') << wxFontMapperBase::GetEncodingName(encSys);
searchPath << GetFullSearchPath(fullname) << wxPATH_SEP;
}
#endif // wxUSE_FONTMAP
searchPath += GetFullSearchPath(szDirPrefix);
- size_t sublocaleIndex = szDirPrefix.find(wxT('_'));
+ size_t sublocaleIndex = szDirPrefix.find(wxS('_'));
if ( sublocaleIndex != wxString::npos )
{
// also add just base locale name: for things like "fr_BE" (belgium
NoTransErr noTransErr;
wxLogVerbose(_("looking for catalog '%s' in path '%s'."),
szName, searchPath.c_str());
- wxLogTrace(TRACE_I18N, _T("Looking for \"%s.mo\" in \"%s\""),
+ wxLogTrace(TRACE_I18N, wxS("Looking for \"%s.mo\" in \"%s\""),
szName, searchPath.c_str());
wxFileName fn(szName);
- fn.SetExt(_T("mo"));
+ fn.SetExt(wxS("mo"));
wxString strFullName;
#if wxUSE_FILESYSTEM
#endif // wxUSE_FILESYSTEM/!wxUSE_FILESYSTEM
{
wxLogVerbose(_("catalog file for domain '%s' not found."), szName);
- wxLogTrace(TRACE_I18N, _T("Catalog \"%s.mo\" not found"), szName);
+ wxLogTrace(TRACE_I18N, wxS("Catalog \"%s.mo\" not found"), szName);
return false;
}
// open file and read its data
wxLogVerbose(_("using catalog '%s' from '%s'."), szName, strFullName.c_str());
- wxLogTrace(TRACE_I18N, _T("Using catalog \"%s\"."), strFullName.c_str());
+ wxLogTrace(TRACE_I18N, wxS("Using catalog \"%s\"."), strFullName.c_str());
#if wxUSE_FILESYSTEM
wxFSFile * const fileMsg = fileSys.OpenFile(strFullName);
return false;
size_t nSize = wx_truncate_cast(size_t, lenFile);
- wxASSERT_MSG( nSize == lenFile + size_t(0), _T("message catalog bigger than 4GB?") );
+ wxASSERT_MSG( nSize == lenFile + size_t(0), wxS("message catalog bigger than 4GB?") );
// read the whole file in memory
if ( fileMsg.Read(m_data.GetWriteBuf(nSize), nSize) != lenFile )
{
// Extract the charset:
wxString header = wxString::FromAscii(StringAtOfs(m_pTransTable, 0));
- int begin = header.Find(wxT("Content-Type: text/plain; charset="));
+ int begin = header.Find(wxS("Content-Type: text/plain; charset="));
if (begin != wxNOT_FOUND)
{
begin += 34; //strlen("Content-Type: text/plain; charset=")
if (end != size_t(-1))
{
m_charset.assign(header, begin, end - begin);
- if (m_charset == wxT("CHARSET"))
+ if (m_charset == wxS("CHARSET"))
{
// "CHARSET" is not valid charset, but lazy translator
m_charset.Clear();
// else: incorrectly filled Content-Type header
// Extract plural forms:
- begin = header.Find(wxT("Plural-Forms:"));
+ begin = header.Find(wxS("Plural-Forms:"));
if (begin != wxNOT_FOUND)
{
begin += 13;
#elif wxUSE_FONTMAP
wxASSERT_MSG( msgIdCharset.empty(),
- _T("non-ASCII msgid languages only supported if wxUSE_WCHAR_T=1") );
+ wxS("non-ASCII msgid languages only supported if wxUSE_WCHAR_T=1") );
wxEncodingConverter converter;
if ( convertEncoding )
bool bConvertEncoding)
{
wxASSERT_MSG( !m_initialized,
- _T("you can't call wxLocale::Init more than once") );
+ wxS("you can't call wxLocale::Init more than once") );
m_initialized = true;
m_strLocale = name;
szLocale = shortName;
wxCHECK_MSG( !szLocale.empty(), false,
- _T("no locale to set in wxLocale::Init()") );
+ wxS("no locale to set in wxLocale::Init()") );
}
#ifdef __WXWINCE__
bool bOk = true;
if ( bLoadDefault )
{
- bOk = AddCatalog(wxT("wxstd"));
+ bOk = AddCatalog(wxS("wxstd"));
// there may be a catalog with toolkit specific overrides, it is not
// an error if this does not exist
wxString port(wxPlatformInfo::Get().GetPortIdName());
if ( !port.empty() )
{
- AddCatalog(port.BeforeFirst(wxT('/')).MakeLower());
+ AddCatalog(port.BeforeFirst(wxS('/')).MakeLower());
}
}
}
{
wxString buf(lc);
wxString buf2;
- buf2 = buf + wxT(".UTF-8");
+ buf2 = buf + wxS(".UTF-8");
l = wxSetlocale(c, buf2);
if ( !l )
{
- buf2 = buf + wxT(".utf-8");
+ buf2 = buf + wxS(".utf-8");
l = wxSetlocale(c, buf2);
}
if ( !l )
{
- buf2 = buf + wxT(".UTF8");
+ buf2 = buf + wxS(".UTF8");
l = wxSetlocale(c, buf2);
}
if ( !l )
{
- buf2 = buf + wxT(".utf8");
+ buf2 = buf + wxS(".utf8");
l = wxSetlocale(c, buf2);
}
}
// Unknown language:
if (info == NULL)
{
- wxLogError(wxT("Unknown language %i."), lang);
+ wxLogError(wxS("Unknown language %i."), lang);
return false;
}
wxFontMapperBase::GetAllEncodingNames(wxFONTENCODING_UTF8);
while ( *names )
{
- retloc = wxSetlocale(LC_ALL, locale + _T('.') + *names++);
+ retloc = wxSetlocale(LC_ALL, locale + wxS('.') + *names++);
if ( retloc )
break;
}
// Some C libraries (namely glibc) still use old ISO 639,
// so will translate the abbrev for them
wxString localeAlt;
- if ( langOnly == wxT("he") )
- localeAlt = wxT("iw") + locale.Mid(3);
- else if ( langOnly == wxT("id") )
- localeAlt = wxT("in") + locale.Mid(3);
- else if ( langOnly == wxT("yi") )
- localeAlt = wxT("ji") + locale.Mid(3);
- else if ( langOnly == wxT("nb") )
- localeAlt = wxT("no_NO");
- else if ( langOnly == wxT("nn") )
- localeAlt = wxT("no_NY");
+ if ( langOnly == wxS("he") )
+ localeAlt = wxS("iw") + locale.Mid(3);
+ else if ( langOnly == wxS("id") )
+ localeAlt = wxS("in") + locale.Mid(3);
+ else if ( langOnly == wxS("yi") )
+ localeAlt = wxS("ji") + locale.Mid(3);
+ else if ( langOnly == wxS("nb") )
+ localeAlt = wxS("no_NO");
+ else if ( langOnly == wxS("nn") )
+ localeAlt = wxS("no_NY");
if ( !localeAlt.empty() )
{
{
if (info->WinLang == 0)
{
- wxLogWarning(wxT("Locale '%s' not supported by OS."), name.c_str());
+ wxLogWarning(wxS("Locale '%s' not supported by OS."), name.c_str());
// retloc already set to "C"
}
else
// because SetThreadLocale does not modify change the
// interpretation of setlocale(LC_ALL, "") call:
wxChar buffer[256];
- buffer[0] = wxT('\0');
+ buffer[0] = wxS('\0');
GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, buffer, 256);
locale << buffer;
if (GetLocaleInfo(lcid, LOCALE_SENGCOUNTRY, buffer, 256) > 0)
- locale << wxT("_") << buffer;
+ locale << wxS("_") << buffer;
if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buffer, 256) > 0)
{
codepage = wxAtoi(buffer);
if (codepage != 0)
- locale << wxT(".") << buffer;
+ locale << wxS(".") << buffer;
}
if (locale.empty())
{
- wxLogLastError(wxT("SetThreadLocale"));
+ wxLogLastError(wxS("SetThreadLocale"));
ret = false;
}
else
wxChar buffer[16];
if (GetLocaleInfo(LOCALE_USER_DEFAULT,
LOCALE_IDEFAULTANSICODEPAGE, buffer, 16) > 0 &&
- wxStrcmp(buffer, wxT("0")) == 0)
+ wxStrcmp(buffer, wxS("0")) == 0)
{
retloc = "C";
}
str.reset(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleCountryCode)));
langFull += str.AsString();
#else
- if (!wxGetEnv(wxT("LC_ALL"), &langFull) &&
- !wxGetEnv(wxT("LC_MESSAGES"), &langFull) &&
- !wxGetEnv(wxT("LANG"), &langFull))
+ if (!wxGetEnv(wxS("LC_ALL"), &langFull) &&
+ !wxGetEnv(wxS("LC_MESSAGES"), &langFull) &&
+ !wxGetEnv(wxS("LANG"), &langFull))
{
// no language specified, treat it as English
return wxLANGUAGE_ENGLISH_US;
}
- if ( langFull == _T("C") || langFull == _T("POSIX") )
+ if ( langFull == wxS("C") || langFull == wxS("POSIX") )
{
// default C locale is English too
return wxLANGUAGE_ENGLISH_US;
//
// we don't use the modifiers neither but we probably should translate
// "euro" into iso885915
- size_t posEndLang = langFull.find_first_of(_T("@."));
+ size_t posEndLang = langFull.find_first_of(wxS("@."));
if ( posEndLang != wxString::npos )
{
langFull.Truncate(posEndLang);
// do we have just the language (or sublang too)?
bool justLang = langFull.length() == LEN_LANG;
if ( justLang ||
- (langFull.length() == LEN_FULL && langFull[LEN_LANG] == wxT('_')) )
+ (langFull.length() == LEN_FULL && langFull[LEN_LANG] == wxS('_')) )
{
// 0. Make sure the lang is according to latest ISO 639
// (this is necessary because glibc uses iw and in instead
wxString langOrig = ExtractLang(langFull);
wxString lang;
- if ( langOrig == wxT("iw"))
- lang = _T("he");
- else if (langOrig == wxT("in"))
- lang = wxT("id");
- else if (langOrig == wxT("ji"))
- lang = wxT("yi");
- else if (langOrig == wxT("no_NO"))
- lang = wxT("nb_NO");
- else if (langOrig == wxT("no_NY"))
- lang = wxT("nn_NO");
- else if (langOrig == wxT("no"))
- lang = wxT("nb_NO");
+ if ( langOrig == wxS("iw"))
+ lang = wxS("he");
+ else if (langOrig == wxS("in"))
+ lang = wxS("id");
+ else if (langOrig == wxS("ji"))
+ lang = wxS("yi");
+ else if (langOrig == wxS("no_NO"))
+ lang = wxS("nb_NO");
+ else if (langOrig == wxS("no_NY"))
+ lang = wxS("nn_NO");
+ else if (langOrig == wxS("no"))
+ lang = wxS("nb_NO");
else
lang = langOrig;
#if defined(__WIN32__) && !defined(__WXMICROWIN__)
// FIXME: what is the error return value for GetACP()?
UINT codepage = ::GetACP();
- encname.Printf(_T("windows-%u"), codepage);
+ encname.Printf(wxS("windows-%u"), codepage);
#elif defined(__WXMAC__)
// default is just empty string, this resolves to the default system
// encoding later
break;
}
- if ( wxStricmp(locale, info->CanonicalName.BeforeFirst(_T('_'))) == 0 )
+ if ( wxStricmp(locale, info->CanonicalName.BeforeFirst(wxS('_'))) == 0 )
{
// a match -- but maybe we'll find an exact one later, so continue
// looking
NoTransErr noTransErr;
wxLogTrace(TRACE_I18N,
- _T("string \"%s\"[%ld] not found in %slocale '%s'."),
+ wxS("string \"%s\"[%ld] not found in %slocale '%s'."),
origString, (long)n,
- domain.empty()
- ? (const wxChar*)wxString::Format(_T("domain '%s' "), domain).c_str()
- : _T(""),
+ wxString::Format(wxS("domain '%s' "), domain).c_str(),
m_strLocale.c_str());
}
#endif // __WXDEBUG__
// Every header is separated by \n
- size_t endLine = trans->find(wxT('\n'), found);
+ size_t endLine = trans->find(wxS('\n'), found);
size_t len = (endLine == wxString::npos) ?
wxString::npos : (endLine - found);
bool wxLocale::IsAvailable(int lang)
{
const wxLanguageInfo *info = wxLocale::GetLanguageInfo(lang);
- wxCHECK_MSG( info, false, _T("invalid language") );
+ wxCHECK_MSG( info, false, wxS("invalid language") );
#if defined(__WIN32__)
if ( !info->WinLang )
wxString str;
wxChar buffer[256];
size_t count;
- buffer[0] = wxT('\0');
+ buffer[0] = wxS('\0');
switch (index)
{
case wxLOCALE_DECIMAL_POINT:
count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buffer, 256);
if (!count)
- str << wxT(".");
+ str << wxS(".");
else
str << buffer;
break;
case wxSYS_LIST_SEPARATOR:
count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLIST, buffer, 256);
if (!count)
- str << wxT(",");
+ str << wxS(",");
else
str << buffer;
break;
case wxSYS_LEADING_ZERO: // 0 means no leading zero, 1 means leading zero
count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILZERO, buffer, 256);
if (!count)
- str << wxT("0");
+ str << wxS("0");
else
str << buffer;
break;
#endif
default:
- wxFAIL_MSG(wxT("Unknown System String !"));
+ wxFAIL_MSG(wxS("Unknown System String !"));
}
return str;
}
#define LNG(wxlang, canonical, winlang, winsublang, layout, desc) \
info.Language = wxlang; \
- info.CanonicalName = wxT(canonical); \
+ info.CanonicalName = wxS(canonical); \
info.LayoutDirection = layout; \
- info.Description = wxT(desc); \
+ info.Description = wxS(desc); \
SETWINLANG(info, winlang, winsublang) \
AddLanguage(info);
#ifdef __WINDOWS__
::MessageBox(NULL, text.wx_str(), title.wx_str(), MB_OK | MB_ICONSTOP);
#else
- wxFprintf(stderr, _T("%s: %s\n"), title.c_str(), text.c_str());
+ wxFprintf(stderr, wxS("%s: %s\n"), title.c_str(), text.c_str());
fflush(stderr);
#endif
}
// always terminate the program
void wxVLogFatalError(const wxString& format, va_list argptr)
{
- wxSafeShowMessage(_T("Fatal Error"), wxString::FormatV(format, argptr));
+ wxSafeShowMessage(wxS("Fatal Error"), wxString::FormatV(format, argptr));
#ifdef __WXWINCE__
ExitThread(3);
{
if ( wxLog::IsEnabled() && wxLog::IsAllowedTraceMask(mask) ) {
wxString msg;
- msg << _T("(") << mask << _T(") ") << wxString::FormatV(format, argptr);
+ msg << wxS("(") << mask << wxS(") ") << wxString::FormatV(format, argptr);
wxLog::OnLog(wxLOG_Trace, msg, time(NULL));
}
ms_prevCounter),
ms_prevCounter);
#else
- msg.Printf(wxT("The previous message was repeated %lu times."),
+ msg.Printf(wxS("The previous message was repeated %lu times."),
ms_prevCounter);
#endif
ms_prevCounter = 0;
ms_timestamp, wxLocaltime_r(&timeNow, &tm));
str->Empty();
- *str << buf << wxT(": ");
+ *str << buf << wxS(": ");
}
#endif // wxUSE_DATETIME
}
case wxLOG_Debug:
#ifdef __WXDEBUG__
{
- wxString msg = level == wxLOG_Trace ? wxT("Trace: ")
- : wxT("Debug: ");
+ wxString msg = level == wxLOG_Trace ? wxS("Trace: ")
+ : wxS("Debug: ");
msg << szString;
LogString(msg, t);
}
DoLogString((const char*)szString.mb_str(), t);
DoLogString((const wchar_t*)szString.wc_str(), t);
#else
- wxFAIL_MSG(wxT("DoLogString must be overriden if it's called."));
+ wxFAIL_MSG(wxS("DoLogString must be overriden if it's called."));
wxUnusedVar(szString);
wxUnusedVar(t);
#endif
if ( !m_str.empty() )
{
wxMessageOutputBest out;
- out.Printf(_T("%s"), m_str.c_str());
+ out.Printf(wxS("%s"), m_str.c_str());
m_str.clear();
}
}
str += szString;
wxMessageOutputDebug dbgout;
- dbgout.Printf(_T("%s\n"), str.c_str());
+ dbgout.Printf(wxS("%s\n"), str.c_str());
}
#endif // __WXDEBUG__
break;
void wxLogBuffer::DoLogString(const wxString& szString, time_t WXUNUSED(t))
{
- m_str << szString << _T("\n");
+ m_str << szString << wxS("\n");
}
// ----------------------------------------------------------------------------
str << szString;
wxFputs(str, m_fp);
- wxFputc(_T('\n'), m_fp);
+ wxFputc(wxS('\n'), m_fp);
fflush(m_fp);
// under GUI systems such as Windows or Mac, programs usually don't have
if ( traits && !traits->HasStderr() )
{
wxMessageOutputDebug dbgout;
- dbgout.Printf(_T("%s\n"), str.c_str());
+ dbgout.Printf(wxS("%s\n"), str.c_str());
}
}
}
size_t wxLog::ms_suspendCount = 0;
-wxString wxLog::ms_timestamp(wxT("%X")); // time only, no date
+wxString wxLog::ms_timestamp(wxS("%X")); // time only, no date
wxTraceMask wxLog::ms_ulTraceMask = (wxTraceMask)0;
wxArrayString wxLog::ms_aTraceMasks;
{
// if this happens, something is seriously wrong, so don't use _() here
// for safety
- wxSprintf(s_szBuf, _T("unknown error %lx"), nErrCode);
+ wxSprintf(s_szBuf, wxS("unknown error %lx"), nErrCode);
return s_szBuf;
}
if( lpMsgBuf != 0 )
{
wxStrncpy(s_szBuf, (const wxChar *)lpMsgBuf, WXSIZEOF(s_szBuf) - 1);
- s_szBuf[WXSIZEOF(s_szBuf) - 1] = wxT('\0');
+ s_szBuf[WXSIZEOF(s_szBuf) - 1] = wxS('\0');
LocalFree(lpMsgBuf);
size_t len = wxStrlen(s_szBuf);
if ( len > 0 ) {
// truncate string
- if ( s_szBuf[len - 2] == wxT('\r') )
- s_szBuf[len - 2] = wxT('\0');
+ if ( s_szBuf[len - 2] == wxS('\r') )
+ s_szBuf[len - 2] = wxS('\0');
}
}
else
#endif // !__SMARTPHONE__
{
- s_szBuf[0] = wxT('\0');
+ s_szBuf[0] = wxS('\0');
}
return s_szBuf;