这篇教程C++ GetThreadLocale函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetThreadLocale函数的典型用法代码示例。如果您正苦于以下问题:C++ GetThreadLocale函数的具体用法?C++ GetThreadLocale怎么用?C++ GetThreadLocale使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetThreadLocale函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: _wcsnicmpint _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;}
开发者ID:kanbang,项目名称:Colt,代码行数:54,
示例2: UnicodeCtimeintUnicodeCtime( 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;}
开发者ID:mingpen,项目名称:OpenNT,代码行数:48,
示例3: definedCommon::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}
开发者ID:giucam,项目名称:residual,代码行数:60,
示例4: init_localestatic voidinit_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);}
开发者ID:elpollodiablo1,项目名称:Anagramarama--WebOS-Tablet,代码行数:60,
示例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;}
开发者ID:SnakeSolidNL,项目名称:reactos,代码行数:29,
示例6: win32_getlocalestatic 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);}
开发者ID:ampli,项目名称:link-grammar,代码行数:27,
示例7: sizeofchar *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;}
开发者ID:MuniyappanV,项目名称:jdk-source-code,代码行数:32,
示例8: AfxComparePathBOOL 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}
开发者ID:rickerliang,项目名称:OpenNT,代码行数:60,
示例9: api_os_locale_encodingstatic 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;}
开发者ID:mymmsc,项目名称:api,代码行数:35,
示例10: mainint __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;}
开发者ID:Afshintm,项目名称:coreclr,代码行数:57,
|