Internationalization and localization tools


Windows C++ Locale Function

BOOL SetLocaleInfo(LCID Locale, LCTYPE LCType, LPCTSTR lpLCData);

BOOL SetLocaleInfoA(LCID Locale, LCTYPE LCType, LPCSTR lpLCData);

BOOL SetLocaleInfoW(LCID Locale, LCTYPE LCType, LPCWSTR lpLCData);

Internationalization (I18n) Function Overview

The SetLocaleInfo function sets the item of information pointed to by lpLCData, in the user override portion of the user's locale. The function returns a non-zero value if successful; otherwise it returns 0 and sets extended error information that can be obtained by calling GetLastError.

The lpLCData argument must point to a null-terminated string containing the locale information that the function will set. This information must be in the specified LCTYPE's particular format. See the MSDN Library for details on the supported LCType options.

The Locale argument is used by the narrow version of the function, SetLocaleInfoA, and specifies the locale with code page that is used when interpreting the lpLCData information.

SetLocaleInfoA is the narrow version of the function; its argument is a single or multibyte character string.

SetLocaleInfoW is the wide version of the function; its argument is a wide-character string.

I18n Issues

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

Formulate the correct locale to pass into SetLocaleInfo. In an internationalized application, the desired locale may be different from the system's locale. Create the application's locale identifier using MAKELCID, and then pass the resulting identifier into all Win32 locale-dependent calls.

Recommended Replacements*

Use the Generic version of the function rather than explicitly calling the narrow or wide versions. SetLocaleInfo will be mapped to SetLocaleInfoW when the program is compiled with the #define UNICODE switch, and to SetLocaleInfoA otherwise. Using the Generic version facilitates switching between an MBCS and UTF-16 Unicode application.

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

Windows C++ Locale Functions

 

Lingoport internationalization and localization services and software