本文整理汇总了C++中GetThreadLocale函数的典型用法代码示例。如果您正苦于以下问题:C++ GetThreadLocale函数的具体用法?C++ GetThreadLocale怎么用?C++ GetThreadLocale使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetThreadLocale函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _wcsnicmp
int _wcsnicmp(LPCWSTR comp1, LPCWSTR comp2, unsigned int nLen)
{
unsigned int len = XMLString::stringLen( comp1);
unsigned int otherLen = XMLString::stringLen( comp2);
unsigned int countChar = 0;
unsigned int maxChars;
int theResult = 0;
// Determine at what string index the comparison stops.
len = ( len > nLen ) ? nLen : len;
otherLen = ( otherLen > nLen ) ? nLen : otherLen;
maxChars = ( len > otherLen ) ? otherLen : len;
// Handle situation when one argument or the other is NULL
// by returning +/- string length of non-NULL argument (inferred
// from XMLString::CompareNString).
// Obs. Definition of stringLen(XMLCh*) implies NULL ptr and ptr
// to Empty String are equivalent. It handles NULL args, BTW.
if ( !comp1 )
{
// Negative because null ptr (c1) less than string (c2).
return ( 0 - otherLen );
}
if ( !comp2 )
{
// Positive because string (c1) still greater than null ptr (c2).
return len;
}
// Copy const parameter strings (plus terminating nul) into locals.
XMLCh* firstBuf = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate( (++len) * sizeof(XMLCh) );//new XMLCh[ ++len];
XMLCh* secondBuf = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate( (++otherLen) * sizeof(XMLCh) );//new XMLCh[ ++otherLen];
memcpy( firstBuf, comp1, len * sizeof(XMLCh));
memcpy( secondBuf, comp2, otherLen * sizeof(XMLCh));
// Then uppercase both strings, losing their case info.
::LCMapStringW( GetThreadLocale(), LCMAP_UPPERCASE, (LPWSTR)firstBuf, len, (LPWSTR)firstBuf, len);
::LCMapStringW( GetThreadLocale(), LCMAP_UPPERCASE, (LPWSTR)secondBuf, otherLen, (LPWSTR)secondBuf, otherLen);
// Strings are equal until proven otherwise.
while ( ( countChar < maxChars ) && ( !theResult ) )
{
theResult = (int)(firstBuf[countChar]) - (int)(secondBuf[countChar]);
++countChar;
}
XMLPlatformUtils::fgMemoryManager->deallocate(firstBuf);//delete [] firstBuf;
XMLPlatformUtils::fgMemoryManager->deallocate(secondBuf);//delete [] secondBuf;
return theResult;
}
示例2: UnicodeCtime
int
UnicodeCtime(
DWORD * Time,
PTCHAR String,
int StringLength
)
/*++
Routine Description:
This function converts the UTC time expressed in seconds since 1/1/70
to an ASCII String.
Arguments:
Time - Pointer to the number of seconds since 1970 (UTC).
String - Pointer to the buffer to place the ASCII representation.
StringLength - The length of String in bytes.
Return Value:
None.
--*/
{
time_t LocalTime;
struct tm TmTemp;
SYSTEMTIME st;
int cchT=0, cchD;
NetpGmtTimeToLocalTime( (DWORD) *Time, (LPDWORD) & LocalTime );
net_gmtime( &LocalTime, &TmTemp );
st.wYear = (WORD)(TmTemp.tm_year + 1900);
st.wMonth = (WORD)(TmTemp.tm_mon + 1);
st.wDay = (WORD)(TmTemp.tm_mday);
st.wHour = (WORD)(TmTemp.tm_hour);
st.wMinute = (WORD)(TmTemp.tm_min);
st.wSecond = (WORD)(TmTemp.tm_sec);
st.wMilliseconds = 0;
cchD = GetDateFormatW(GetThreadLocale(),0,&st,NULL,String,StringLength);
if (cchD != 0) {
*(String+cchD-1) = TEXT(' '); /* replace NULLC with blank */
cchT = GetTimeFormatW(GetThreadLocale(), TIME_NOSECONDS, &st, NULL, String+cchD, StringLength-cchD);
}
return cchD+cchD;
}
示例3: defined
Common::String OSystem_SDL::getSystemLanguage() const {
#if defined(USE_DETECTLANG) && !defined(_WIN32_WCE)
#ifdef WIN32
// We can not use "setlocale" (at least not for MSVC builds), since it
// will return locales like: "English_USA.1252", thus we need a special
// way to determine the locale string for Win32.
char langName[9];
char ctryName[9];
const LCID languageIdentifier = GetThreadLocale();
// GetLocalInfo is only supported starting from Windows 2000, according to this:
// http://msdn.microsoft.com/en-us/library/dd318101%28VS.85%29.aspx
// On the other hand the locale constants used, seem to exist on Windows 98 too,
// check this for that: http://msdn.microsoft.com/en-us/library/dd464799%28v=VS.85%29.aspx
//
// I am not exactly sure what is the truth now, it might be very well that this breaks
// support for systems older than Windows 2000....
//
// TODO: Check whether this (or ScummVM at all ;-) works on a system with Windows 98 for
// example and if it does not and we still want Windows 9x support, we should definitly
// think of another solution.
if (GetLocaleInfo(languageIdentifier, LOCALE_SISO639LANGNAME, langName, sizeof(langName)) != 0 &&
GetLocaleInfo(languageIdentifier, LOCALE_SISO3166CTRYNAME, ctryName, sizeof(ctryName)) != 0) {
Common::String localeName = langName;
localeName += "_";
localeName += ctryName;
return localeName;
} else {
return ModularBackend::getSystemLanguage();
}
#else // WIN32
// Activating current locale settings
const char *locale = setlocale(LC_ALL, "");
// Detect the language from the locale
if (!locale) {
return ModularBackend::getSystemLanguage();
} else {
int length = 0;
// Strip out additional information, like
// ".UTF-8" or the like. We do this, since
// our translation languages are usually
// specified without any charset information.
for (int i = 0; locale[i]; ++i, ++length) {
// TODO: Check whether "@" should really be checked
// here.
if (locale[i] == '.' || locale[i] == ' ' || locale[i] == '@')
break;
}
return Common::String(locale, length);
}
#endif // WIN32
#else // USE_DETECTLANG
return ModularBackend::getSystemLanguage();
#endif // USE_DETECTLANG
}
示例4: init_locale
static void
init_locale(int argc, char *argv[])
{
char *lang = NULL, *p = NULL;
char buffer[64];
strcpy(language,"i18n/");
if (argc == 2) {
strcat(language, argv[1]);
if (is_valid_locale(language))
return;
}
PDL_GetLanguage(buffer, 64);
//Error("the pdl language is:%s\n",buffer);
//lang = getenv("LANG");
lang = buffer;
lang = strtok(buffer,"_");
if (lang != NULL) {
strcpy(language,"i18n/");
strcat(language, lang);
//Error("lang defined language is:%s\n",language);
if (is_valid_locale(language))
return;
while ((p = strrchr(language, '.')) != NULL) {
*p = 0;
if (is_valid_locale(language))
return;
}
if ((p = strrchr(language, '_')) != NULL) {
*p = 0;
if (is_valid_locale(language))
return;
}
}
#ifdef WIN32
{
LCID lcid = GetThreadLocale();
strcpy(language,"i18n/");
GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME,
language + strlen(language), sizeof(language));
p = language + strlen(language);
strcat(language, "_");
GetLocaleInfo(lcid, LOCALE_SISO3166CTRYNAME,
language + strlen(language), sizeof(language));
Debug("locale %s", language);
if (is_valid_locale(language))
return;
*p = 0;
if (is_valid_locale(language))
return;
}
#endif /* WIN32 */
/* last resort - use the english locale */
//Error("default locale path:%s\n",DEFAULT_LOCALE_PATH);
strcpy(language, DEFAULT_LOCALE_PATH);
//Error("default language is:%s\n",language);
}
示例5: BindCtxImpl_Construct
/******************************************************************************
* BindCtx_Construct (local function)
*******************************************************************************/
static HRESULT BindCtxImpl_Construct(BindCtxImpl* This)
{
TRACE("(%p)\n",This);
/* Initialize the virtual function table.*/
This->IBindCtx_iface.lpVtbl = &VT_BindCtxImpl;
This->ref = 0;
/* Initialize the BIND_OPTS2 structure */
This->bindOption2.cbStruct = sizeof(BIND_OPTS2);
This->bindOption2.grfFlags = 0;
This->bindOption2.grfMode = STGM_READWRITE;
This->bindOption2.dwTickCountDeadline = 0;
This->bindOption2.dwTrackFlags = 0;
This->bindOption2.dwClassContext = CLSCTX_SERVER;
This->bindOption2.locale = GetThreadLocale();
This->bindOption2.pServerInfo = 0;
/* Initialize the bindctx table */
This->bindCtxTableSize=0;
This->bindCtxTableLastIndex=0;
This->bindCtxTable = NULL;
return S_OK;
}
示例6: win32_getlocale
static char *
win32_getlocale (void)
{
char lbuf[10];
char locale[32];
LCID lcid = GetThreadLocale();
if (0 >= GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME, lbuf, sizeof(lbuf)))
{
prt_error("Error: GetLocaleInfoA LOCALE_SENGLISHLANGUAGENAME LCID=%d: "
"Error %d\n", (int)lcid, (int)GetLastError());
return NULL;
}
strcpy(locale, lbuf);
strcat(locale, "-");
if (0 >= GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME, lbuf, sizeof(lbuf)))
{
prt_error("Error: GetLocaleInfoA LOCALE_SISO3166CTRYNAME LCID=%d: "
"Error %d\n", (int)lcid, (int)GetLastError());
return NULL;
}
strcat(locale, lbuf);
return strdup(locale);
}
示例7: sizeof
char *sysGetLocaleStr() {
LCID lcid;
int i;
int len = sizeof(localeIDMap) / sizeof(LCIDtoLocale);
if (!locale_initialized) {
lcid = GetThreadLocale();
/* first look for whole thing */
for (i=0; i< len; i++) {
if (lcid == localeIDMap[i].winID) {
break;
}
}
if (i == len) {
lcid &= 0xff; /* look for just language */
for (i=0; i<len; i++) {
if (lcid == localeIDMap[i].winID) {
break;
}
}
}
if (i < len) {
strncpy(_localeStr, localeIDMap[i].javaID, 64);
} else {
strcpy(_localeStr, "en_US");
}
if (sysStrCaseCmp(_localeStr, "C") == 0) {
strcpy(_localeStr, "en_US");
}
}
return _localeStr;
}
示例8: AfxComparePath
BOOL AFXAPI AfxComparePath(LPCTSTR lpszPath1, LPCTSTR lpszPath2)
{
#ifdef _MAC
FSSpec fssTemp1;
FSSpec fssTemp2;
if (!UnwrapFile(lpszPath1, &fssTemp1) || !UnwrapFile(lpszPath2, &fssTemp2))
return FALSE;
return fssTemp1.vRefNum == fssTemp2.vRefNum &&
fssTemp1.parID == fssTemp2.parID &&
EqualString(fssTemp1.name, fssTemp2.name, false, true);
#else
// use case insensitive compare as a starter
if (lstrcmpi(lpszPath1, lpszPath2) != 0)
return FALSE;
// on non-DBCS systems, we are done
if (!GetSystemMetrics(SM_DBCSENABLED))
return TRUE;
// on DBCS systems, the file name may not actually be the same
// in particular, the file system is case sensitive with respect to
// "full width" roman characters.
// (ie. fullwidth-R is different from fullwidth-r).
int nLen = lstrlen(lpszPath1);
if (nLen != lstrlen(lpszPath2))
return FALSE;
ASSERT(nLen < _MAX_PATH);
// need to get both CT_CTYPE1 and CT_CTYPE3 for each filename
LCID lcid = GetThreadLocale();
WORD aCharType11[_MAX_PATH];
VERIFY(GetStringTypeEx(lcid, CT_CTYPE1, lpszPath1, -1, aCharType11));
WORD aCharType13[_MAX_PATH];
VERIFY(GetStringTypeEx(lcid, CT_CTYPE3, lpszPath1, -1, aCharType13));
WORD aCharType21[_MAX_PATH];
VERIFY(GetStringTypeEx(lcid, CT_CTYPE1, lpszPath2, -1, aCharType21));
#ifdef _DEBUG
WORD aCharType23[_MAX_PATH];
VERIFY(GetStringTypeEx(lcid, CT_CTYPE3, lpszPath2, -1, aCharType23));
#endif
// for every C3_FULLWIDTH character, make sure it has same C1 value
int i = 0;
for (LPCTSTR lpsz = lpszPath1; *lpsz != 0; lpsz = _tcsinc(lpsz))
{
// check for C3_FULLWIDTH characters only
if (aCharType13[i] & C3_FULLWIDTH)
{
ASSERT(aCharType23[i] & C3_FULLWIDTH); // should always match!
// if CT_CTYPE1 is different then file system considers these
// file names different.
if (aCharType11[i] != aCharType21[i])
return FALSE;
}
++i; // look at next character type
}
return TRUE; // otherwise file name is truly the same
#endif
}
示例9: api_os_locale_encoding
static char * api_os_locale_encoding (void)
{
#ifndef API_WINDOWS
char *charset = nl_langinfo(CODESET);
char *cp = strdup(charset);
#else
#ifdef _UNICODE
int i;
#endif
#if defined(_WIN32_WCE)
LCID locale = GetUserDefaultLCID();
#else
LCID locale = GetThreadLocale();
#endif
int len = GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE, NULL, 0);
int size = (len * sizeof(TCHAR)) + 2;
char *cp = malloc(size);
memset(cp, 0x00, size);
if (0 < GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE, (TCHAR*) (cp + 2), len))
{
/* Fix up the returned number to make a valid codepage name of
the form "CPnnnn". */
cp[0] = 'C';
cp[1] = 'P';
#ifdef _UNICODE
for(i = 0; i < len; i++) {
cp[i + 2] = (char) ((TCHAR*) (cp + 2))[i];
}
#endif
return cp;
}
api_snprintf(cp, size, "CP%u", (unsigned) GetACP());
#endif
return cp;
}
示例10: main
int __cdecl main(int argc, char *argv[])
{
LCID lcid;
if (PAL_Initialize(argc, argv))
{
return FAIL;
}
/*
* Passing LOCALE_USER_DEFAULT to IsValidLocale will fail, so instead
* the current thread localed is changed to it, and that lcid is passed
* to IsValidLocale (which should always pass)
*/
if (!SetThreadLocale(LOCALE_USER_DEFAULT))
{
Fail("Unable to set locale to LOCALE_USER_DEFAULT!\n");
}
lcid = GetThreadLocale();
if (!IsValidLocale(lcid, LCID_SUPPORTED))
{
Fail("IsValidLocale found the default user locale unsupported!\n");
}
if (!IsValidLocale(lcid, LCID_INSTALLED))
{
Fail("IsValidLocale found the default user locale uninstalled!\n");
}
/*
* Test out bad parameters
*/
if (IsValidLocale(-1, LCID_SUPPORTED))
{
Fail("IsValideLocale passed with an invalid LCID!\n");
}
if (IsValidLocale(-1, LCID_INSTALLED))
{
Fail("IsValideLocale passed with an invalid LCID!\n");
}
if (IsValidLocale(LOCALE_USER_DEFAULT, LCID_SUPPORTED))
{
Fail("IsValidLocale passed with LOCALE_USER_DEFAULT!\n");
}
if (IsValidLocale(LOCALE_USER_DEFAULT, LCID_INSTALLED))
{
Fail("IsValidLocale passed with LOCALE_USER_DEFAULT!\n");
}
PAL_Terminate();
return PASS;
}
示例11: GetThreadLocale
CJbookletApp::CJbookletApp()
{
// TODO: この位置に構築用のコードを追加してください。
// ここに InitInstance 中の重要な初期化処理をすべて記述してください。
m_langCode = GetThreadLocale();
if ( m_langCode != 0x0411 )
m_langCode = 0x0409; // 「日本語」以外の場合は強制的に「英語」にする
SetThreadLocale( m_langCode );
}
示例12: lstrcmpA
int
APIENTRY
lstrcmpA(
LPCSTR lpString1,
LPCSTR lpString2
)
{
int retval;
retval = CompareStringA( GetThreadLocale(),
LOCALE_USE_CP_ACP,
lpString1,
-1,
lpString2,
-1 );
if (retval == 0)
{
//
// The caller is not expecting failure. Try the system
// default locale id.
//
retval = CompareStringA( GetSystemDefaultLCID(),
LOCALE_USE_CP_ACP,
lpString1,
-1,
lpString2,
-1 );
}
if (retval == 0)
{
if (lpString1 && lpString2)
{
//
// The caller is not expecting failure. We've never had a
// failure indicator before. We'll do a best guess by calling
// the C runtimes to do a non-locale sensitive compare.
//
return strcmp(lpString1, lpString2);
}
else if (lpString1)
{
return (1);
}
else if (lpString2)
{
return (-1);
}
else
{
return (0);
}
}
return (retval - 2);
}
示例13: CheckThreadLocale
bool CheckThreadLocale()
{
if (theApp.GetProfileInt(_T("eMule"), _T("SetLanguageACP"), 0) != 0)
return true;
int iSetSysACP = theApp.GetProfileInt(_T("eMule"), _T("SetSystemACP"), -1);
if (iSetSysACP != -1)
return true;
iSetSysACP = 0;
LCID lcidSystem = GetSystemDefaultLCID(); // Installation, or altered by user in control panel (WinXP)
//LCID lcidUser = GetUserDefaultLCID(); // Installation, or altered by user in control panel (WinXP)
// get the ANSI code page which is to be used for all non-Unicode conversions.
LANGID lidSystem = LANGIDFROMLCID(lcidSystem);
// get user's sorting preferences
//UINT uSortIdUser = SORTIDFROMLCID(lcidUser);
//UINT uSortVerUser = SORTVERSIONFROMLCID(lcidUser);
// we can't use the same sorting paramters for 2 different Languages..
UINT uSortIdUser = SORT_DEFAULT;
UINT uSortVerUser = 0;
// create a thread locale which gives full backward compability for users which had run ANSI emule on
// a system where the system's code page did not match the user's language..
LCID lcidSys = MAKESORTLCID(lidSystem, uSortIdUser, uSortVerUser);
LCID lcidUsr = GetThreadLocale();
if (lcidUsr != lcidSys)
{
CString strUsrCP = GetCodePageNameForLocale(lcidUsr);
if (!strUsrCP.IsEmpty())
strUsrCP = _T(" \"") + strUsrCP + _T('\"');
CString strSysCP = GetCodePageNameForLocale(lcidSys);
if (!strSysCP.IsEmpty())
strSysCP = _T(" \"") + strSysCP + _T('\"');
static const TCHAR szMsg[] =
_T("eMule has detected that your current code page%s is not the same as your system's code page%s. For converting non-Unicode data to Unicode, you need to specify which code page to use.\r\n")
_T("\r\n")
_T("If you want eMule to use your current code page for converting non-Unicode data, click 'Yes'. (If you are using eMule for the first time or if you don't care about this issue at all, choose this option. This is the recommended setting.)\r\n")
_T("\r\n")
_T("If you want eMule to use your system's code page for converting non-Unicode data, click 'No'. (This will give you more backward compatibility when reading older *.met files created with non-Unicode eMule versions.)\r\n")
_T("\r\n")
_T("If you want to cancel and create backup of all your configuration files or visit our forum to learn more about this issue, click 'Cancel'.\r\n")
;
CString strFullMsg;
strFullMsg.Format(szMsg, strUsrCP, strSysCP);
int iAnswer = AfxMessageBox(strFullMsg, MB_ICONSTOP | MB_YESNOCANCEL | MB_DEFBUTTON1);
if (iAnswer == IDCANCEL)
return false;
if (iAnswer == IDNO)
iSetSysACP = 1;
}
VERIFY( theApp.WriteProfileInt(_T("eMule"), _T("SetSystemACP"), iSetSysACP) );
return true;
}
示例14: c_win32_getlocale
char *
c_win32_getlocale(void)
{
LCID lcid = GetThreadLocale();
char buf[19];
int ccBuf = GetLocaleInfo(lcid, LOCALE_SISO639LANGNAME, buf, 9);
buf[ccBuf - 1] = '-';
ccBuf += GetLocaleInfo(lcid, LOCALE_SISO3166CTRYNAME, buf + ccBuf, 9);
return strdup(buf);
}
示例15: main
int __cdecl main(int argc, char *argv[])
{
LCID lcid;
LANGID LangID;
if (PAL_Initialize(argc, argv))
{
return FAIL;
}
LangID = GetSystemDefaultLangID();
if (LangID == 0)
{
Fail("GetSystemDefaultLangID failed!\n");
}
/* Try using the langid (with default sort) as a locale */
if (!SetThreadLocale(MAKELCID(LangID, SORT_DEFAULT)))
{
Fail("Unable to use GetSystemDefaultLangID as a locale!\n");
}
lcid = GetThreadLocale();
if (!IsValidLocale(lcid, LCID_INSTALLED))
{
Fail("Unable to use GetSystemDefaultLangID as a locale!\n");
}
/* Make sure results consistent with using LOCALE_USER_DEFAULT */
if (!SetThreadLocale(LOCALE_USER_DEFAULT))
{
Fail("Unexpected error testing GetSystemDefaultLangID!\n");
}
if (GetThreadLocale() != lcid)
{
Fail("Results from GetSystemDefaultLangID inconsistent with "
"LOCALE_USER_DEFAULT!\n");
}
PAL_Terminate();
return PASS;
}