Internationalization and localization tools


Locale-Sensitive Windows C++ Function

int GetCalendarInfo(LCID Locale, CALID Calendar, CALTYPE CalType, LPTSTR lpCalData, int cchData, LPDWORD lpValue);

int GetCalendarInfoA(LCID Locale, CALID Calendar, CALTYPE CalType, LPSTR lpCalData, int cchData, LPDWORD lpValue);

int GetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType, LPWSTR lpCalData, int cchData, LPDWORD lpValue);

Internationalization (I18n) Function Overview

The GetCalendarInfo function retrieves information about the calendar specified by Calendar and CalType, based on the locale specified by Locale, and stores the resulting string in the buffer pointed to by lpCalData. It returns the number of TCHARs written to lpCalData if successful; else it returns 0 and sets extended error information that can be obtained by calling GetLastError.

cchData should be set to either the size, in TCHARs, of the lpCalData buffer, or to 0, in which case, the function returns the number of TCHARs required to hold the information, and the buffer pointed to by lpCalData is not used. Also, if CAL_RETURN_NUMBER is specified in CalType, then cchData must be 0 and lpValue will be set to a variable that receives the requested data as a number.

GetCalendarInfoA is the narrow version of the function, where lpCalData is a single or multibyte string and cchData is a byte length value.

GetCalendarInfoW is the wide version of the function, where lpCalData is a wide-character string and cchData is a wide-character (WCHAR) length value.

See the MSDN library for additional information.

I18n Issues

Use the appropriate version of the function as required for internationalization support, noting the following:

Formulate the correct LCID to pass into GetCalendarInfo. Although there are two predefined LCID constants that may be used: LOCALE_SYSTEM_DEFAULT (the system's default locale returned by GetSystemDefaultLCID) and LOCALE_USER_DEFAULT (the current user's default locale returned by GetUserDefaultLCID), neither of these will work in an internationalized application where the locale is independent of the user's system settings.

Ensure that if cchData is non-zero, it is set correctly for the chosen platform; bytes for the narrow version and WCHARs for the wide version. See Locale-Sensitive Length Functions for a discussion on multibyte and wide character sizes.

Recommended Replacements*

When possible, use the Generic version of the function, rather than the narrow or wide versions, and let the Windows #define UNICODE switch determine which version of the function will be called.

*If you're already using the recommended function, see I18n Issues for other reasons why Globalyzer is detecting the function.

Locale-Sensitive Windows C++ Functions

 

Lingoport internationalization and localization services and software