Locale-Sensitive Windows C++ Function
int GetCurrencyFormat(LCID Locale, DWORD dwFlags, LPCTSTR lpValue, CONST CURRENCYFMT *lpFormat, LPTSTR lpCurrencyStr, int cchCurrency);
int GetCurrencyFormatA(LCID Locale, DWORD dwFlags, LPCSTR lpValue, CONST CURRENCYFMT *lpFormat, LPSTR lpCurrencyStr, int cchCurrency);
int GetCurrencyFormatW(LCID Locale, DWORD dwFlags, LPCWSTR lpValue, CONST CURRENCYFMT *lpFormat, LPWSTR lpCurrencyStr, int cchCurrency);
Internationalization (I18n) Function Overview
The GetCurrencyFormat function formats the number string lpValue
into a currency string based on the
locale specified by Locale and the options specified
by dwFlags and lpFormat , and stores the resulting currency string in lpCurrencyStr .
If successful, it returns the number of TCHARs , including the null-terminating character,
written to lpCurrencyStr . In the event of an error, GetCurrencyFormat returns 0 and
sets extended error information that can be obtained by calling GetLastError .
cchCurrency should be set to either the size, in TCHARs , of the
lpCurrencyStr 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
lpCurrencyStr is not used.
GetCurrencyFormatA is the narrow version of the function, where lpValue and lpCurrencyStr
are single or multibyte strings and cchCurrency and the return are byte length values.
GetCurrencyFormatW is the wide version of the function, where lpValue and lpCurrencyStr
are wide-character strings and cchCurrency and the return are wide-character (WCHAR ) length values.
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 locale to pass into GetCurrencyFormat .
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 cchCurrency 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.
|