本文整理匯總了C++中GetLocaleInfo函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetLocaleInfo函數的具體用法?C++ GetLocaleInfo怎麽用?C++ GetLocaleInfo使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetLocaleInfo函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: getFirstDayOfWeek
int getFirstDayOfWeek()
{
// Let's make it's sunday by default
int result = 0;
GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, (LPWSTR)&result, 2);
// GetLocaleInfo returns numeric char '0' - '6'
// Hence, just subtracting...
result -= '0';
return result;
}
示例2: measurementSystem
QVariant QSystemLocalePrivate::measurementSystem()
{
wchar_t output[2];
if (GetLocaleInfo(lcid, LOCALE_IMEASURE, output, 2)) {
QString iMeasure = QString::fromWCharArray(output);
if (iMeasure == QLatin1String("1")) {
return QLocale::ImperialSystem;
}
}
return QLocale::MetricSystem;
}
示例3: DecimalPoint
TCHAR CLocale::DecimalPoint()
{
// TODO should really allow multiple character decimal point markers
// although I'm not sure if any languages use them.
TCHAR Buf[10];
if (GetLocaleInfo(m_LocaleID, LOCALE_SDECIMAL, Buf, sizeof(Buf)))
{
if (strlen(Buf) == 1)
return (Buf[0]);
}
// default
return (TCHAR('.'));
}
示例4: IsTime24
BOOL IsTime24()
{
DWORD dwTime24 = 0;
wchar_t wsTime24[10] = L"1";
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ITIME, wsTime24, 10))
{
if (wcsicmp(wsTime24, L"0") == 0)
dwTime24 = 0;
else if (wcsicmp(wsTime24, L"1") == 0)
dwTime24 = 1;
}
return dwTime24 ? TRUE : FALSE;
}
示例5: DisplayPackInfo
static void DisplayPackInfo(HWND hwndDlg, const LANGPACK_INFO *pack)
{
/* locale string */
if (!(pack->flags & LPF_NOLOCALE)) {
TCHAR szLocaleName[256], szLanguageName[128], szContryName[128];
if (!GetLocaleInfo(pack->Locale, WINVER >= _WIN32_WINNT_WIN7 ? LOCALE_SENGLISHLANGUAGENAME : LOCALE_SENGLANGUAGE, szLanguageName, _countof(szLanguageName)))
szLanguageName[0] = _T('\0');
if (!GetLocaleInfo(pack->Locale, WINVER >= _WIN32_WINNT_WIN7 ? LOCALE_SENGLISHCOUNTRYNAME : LOCALE_SENGCOUNTRY, szContryName, _countof(szContryName)))
szContryName[0] = _T('\0');
/* add some note if its incompatible */
if (szLanguageName[0] && szContryName[0]) {
mir_sntprintf(szLocaleName, _T("%s (%s)"), TranslateTS(szLanguageName), TranslateTS(szContryName));
if (!IsValidLocale(pack->Locale, LCID_INSTALLED)) {
TCHAR *pszIncompat;
pszIncompat = TranslateT("(incompatible)");
szLocaleName[_countof(szLocaleName) - mir_tstrlen(pszIncompat) - 1] = 0;
mir_tstrcat(mir_tstrcat(szLocaleName, _T(" ")), pszIncompat);
}
SetDlgItemText(hwndDlg, IDC_LANGLOCALE, szLocaleName);
}
else SetDlgItemText(hwndDlg, IDC_LANGLOCALE, TranslateT("Unknown"));
}
else SetDlgItemText(hwndDlg, IDC_LANGLOCALE, TranslateT("Unknown"));
/* file date */
SYSTEMTIME stFileDate;
TCHAR szDate[128]; szDate[0] = 0;
if (FileTimeToSystemTime(&pack->ftFileDate, &stFileDate))
GetDateFormat(Langpack_GetDefaultLocale(), DATE_SHORTDATE, &stFileDate, NULL, szDate, _countof(szDate));
SetDlgItemText(hwndDlg, IDC_LANGDATE, szDate);
/* general */
SetDlgItemText_CP(hwndDlg, IDC_LANGMODUSING, pack->szLastModifiedUsing);
SetDlgItemText_CP(hwndDlg, IDC_LANGAUTHORS, pack->szAuthors);
SetDlgItemText_CP(hwndDlg, IDC_LANGEMAIL, pack->szAuthorEmail);
SetDlgItemText(hwndDlg, IDC_LANGINFOFRAME, TranslateTS(pack->tszLanguage));
}
示例6: _imp_getProcessLocale
void _imp_getProcessLocale( rtl_Locale ** ppLocale )
{
WCHAR langCode[ELP_LANGUAGE_FIELD_LENGTH];
WCHAR ctryCode[ELP_COUNTRY_FIELD_LENGTH];
LCID localeId;
OSL_ASSERT( ppLocale );
/* get the LCID to retrieve information from */
localeId = GetUserDefaultLCID();
/* call GetLocaleInfo to retrieve the iso codes */
if( GetLocaleInfo( localeId, LOCALE_SISO639LANGNAME , langCode, ELP_LANGUAGE_FIELD_LENGTH ) &&
GetLocaleInfo( localeId, LOCALE_SISO3166CTRYNAME , ctryCode, ELP_COUNTRY_FIELD_LENGTH ) )
{
*ppLocale = rtl_locale_register( langCode, ctryCode, L"" );
}
else
{
*ppLocale = rtl_locale_register( L"C", L"", L"" );
}
}
示例7: test_codeset3
void test_codeset3()
{
int ret;
CALID calid;
DWORD value;
LOCALESIGNATURE LocSig;
value = 0;
memset(&LocSig,0,sizeof(LOCALESIGNATURE));
ret = GetLocaleInfo(LOCALE_USER_DEFAULT,
LOCALE_ICALENDARTYPE | LOCALE_RETURN_NUMBER,
(LPTSTR)&value,
sizeof(value) / sizeof(TCHAR) );
if (ret) {
printf("GetLocaleInfo:1: returned %ld ... value %lu\n", ret, value);
} else {
ret = GetLastError();
printf("GetLocaleInfo:2: returned error %d... value %lu\n", ret, value );
}
calid = value;
ret = GetLocaleInfo(LOCALE_USER_DEFAULT,
LOCALE_FONTSIGNATURE,
(LPTSTR)&LocSig,
sizeof(LocSig) / sizeof(TCHAR) );
if (ret) {
printf("GetLocaleInfo:2: returned %ld ...\n", ret);
show_hexified( (char *)&LocSig, sizeof(LOCALESIGNATURE), 0 );
} else {
ret = GetLastError();
printf("GetLocaleInfo:2: returned error %d... \n", ret );
}
}
示例8: InitShortDateCB
/* Init short date control box */
VOID
InitShortDateCB(HWND hwndDlg, LCID lcid)
{
TCHAR szShortDateFmt[MAX_SAMPLES_STR_SIZE];
INT nRetCode;
/* Limit text lengths */
SendMessage(GetDlgItem(hwndDlg, IDC_SHRTDATEFMT_COMBO),
CB_LIMITTEXT,
MAX_SHRTDATEFMT,
0);
SendMessage(GetDlgItem(hwndDlg, IDC_SHRTDATESEP_COMBO),
CB_LIMITTEXT,
MAX_SHRTDATESEP,
0);
/* Get current short date format */
GetLocaleInfo(lcid,
LOCALE_SSHORTDATE,
szShortDateFmt,
MAX_SAMPLES_STR_SIZE);
/* Clear all box content */
SendMessage(GetDlgItem(hwndDlg, IDC_SHRTDATEFMT_COMBO),
CB_RESETCONTENT,
(WPARAM)0,
(LPARAM)0);
/* Enumerate short date formats */
hwndEnum = GetDlgItem(hwndDlg, IDC_SHRTDATEFMT_COMBO);
EnumDateFormats(ShortDateFormatEnumProc, lcid, DATE_SHORTDATE);
/* Set current item to value from registry */
nRetCode = SendMessage(GetDlgItem(hwndDlg, IDC_SHRTDATEFMT_COMBO),
CB_SELECTSTRING,
-1,
(LPARAM)szShortDateFmt);
/* If it is not successful, add new value to list and select them */
if (nRetCode == CB_ERR)
{
SendMessage(GetDlgItem(hwndDlg, IDC_SHRTDATEFMT_COMBO),
CB_ADDSTRING,
0,
(LPARAM)szShortDateFmt);
SendMessage(GetDlgItem(hwndDlg, IDC_SHRTDATEFMT_COMBO),
CB_SELECTSTRING,
-1,
(LPARAM)szShortDateFmt);
}
}
示例9: GetLocaleInfo
/********************************************
StringToNumber
Purpose
Converts a string to a number.
This function will work with strings
containing characters other than numbers,
by removing non-digit characters before the
conversion. Therefore it will work with
strings such as: "$123,456.00","123-456-789"
Params
string - string to convert
number - resulting number
Return
UG_SUCCESS success
UG_ERROR fail
*********************************************/
int CUGCell::StringToNumber(CString *string,double *number)
{
CString tempString;
tempString = *string;
// remove localized thousand separators
TCHAR szThousandSep[4];
GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, szThousandSep, 4);
tempString.Replace( szThousandSep, _T("") );
// remove localized currency indicators
TCHAR szCurrencyMark[6];
GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SCURRENCY, szCurrencyMark, 6);
tempString.Replace( szCurrencyMark, _T("") );
// Replace the localized decimal separator with the standard, which is
// understood by the _ttol function
TCHAR szDecimalSep[4];
GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, szDecimalSep, 4);
tempString.Replace( szDecimalSep, _T(".") );
// parse the string to its numeric value
*number = ::_tcstod(tempString, NULL);
return UG_SUCCESS;
}
示例10: srand
char *rndnickcountry(char *strbuf)
{
char temp[10];
srand(GetTickCount());
GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SABBREVCTRYNAME, temp, sizeof(temp));
_snprintf(strbuf, MAXNICKLEN, "%s|", temp);
for (int i=0;i < maxrand;i++)
_snprintf(strbuf, MAXNICKLEN, "%s%i", strbuf, rand()%10);
return (strbuf);
}
示例11: Time_GetAMPMSize
void Time_GetAMPMSize (HDC hdc, SIZE *pSize, LPTSTR pszAM, LPTSTR pszPM)
{
TCHAR szAM[ cchRESOURCE ];
TCHAR szPM[ cchRESOURCE ];
if (!pszAM)
pszAM = szAM;
if (!pszPM)
pszPM = szPM;
if (!GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_S1159, pszAM, cchRESOURCE))
lstrcpy (pszAM, TEXT("AM"));
if (!GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_S2359, pszPM, cchRESOURCE))
lstrcpy (pszPM, TEXT("PM"));
SIZE sAM; // size of "AM"
GetTextExtentPoint (hdc, pszAM, lstrlen(pszAM), &sAM);
SIZE sPM; // size of "PM"
GetTextExtentPoint (hdc, pszPM, lstrlen(pszPM), &sPM);
pSize->cx = max( sAM.cx, sPM.cx );
pSize->cy = max( sAM.cy, sPM.cy );
}
示例12: SetLocale
BOOL CLocale::SetLocale(LCID LocaleID)
{
TCHAR Buf[4];
if (GetLocaleInfo(LocaleID, LOCALE_SABBREVLANGNAME, Buf, sizeof(Buf)))
{
TCHAR *LocName = _tsetlocale(LC_ALL, Buf);
if (LocName)
{
m_csLocaleName = LocName;
m_LocaleID = LocaleID;
}
}
return (LocaleID == m_LocaleID);
}
示例13: defined
int MDateTimeHelper::hourMode()
{
bool format12h = false;
#if defined(Q_OS_WIN)
wchar_t data[10];
GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, data, 10);
format12h = QString::fromWCharArray(data).startsWith(QLatin1Char('h'));
#elif defined(HAVE_MEEGOTOUCH)
format12h = (MLocale().timeFormat24h() == MLocale::TwelveHourTimeFormat24h ? true :
(MLocale().timeFormat24h() == MLocale::TwentyFourHourTimeFormat24h ? false :
MLocale().defaultTimeFormat24h() == MLocale::TwelveHourTimeFormat24h));
#endif
return format12h ? TwelveHours : TwentyFourHours;
}
示例14: defined
int SDateTime::hourMode()
{
bool format12h = false;
#if defined(Q_OS_WIN)
wchar_t data[10];
GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, data, 10);
format12h = QString::fromWCharArray(data).startsWith(QLatin1Char('h'));
#elif defined(Q_OS_SYMBIAN)
TExtendedLocale loc;
loc.LoadSystemSettings();
format12h = loc.GetLocale()->TimeFormat() == ETime12;
#endif
return format12h ? TwelveHours : TwentyFourHours;
}
示例15: GetLocaleInfo
CString Util::GetMyDate(void)
{
CString strDate;
SYSTEMTIME time;
int n = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, 0, 0);
if(n != 0){
char *szFormat = new char[n];
ZeroMemory(szFormat, n);
n = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, szFormat, n);
GetLocalTime(&time);
n = GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &time, szFormat, 0, 0);
if(n != 0){
char *szDate = new char[n];
ZeroMemory(szDate, n);
n = GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &time, szFormat, szDate, n);
strDate = szDate;
delete szDate;
szDate = 0;
}
delete szFormat;
szFormat = 0;
}
return strDate;
}