Formats a number string as a number string customized for a locale specified by name.
Note
The application should call this function in preference to GetNumberFormat if designed to run only on Windows Vista and later.
Note
This function can format data that changes between releases, for example, due to a custom locale. If your application must persist or transmit data, see Using Persistent Locale Data.
int GetNumberFormatEx(
LPCWSTR lpLocaleName,
DWORD dwFlags,
LPCWSTR lpValue,
const NUMBERFMTW *lpFormat,
_Out_writes_opt_(cchNumber)LPWSTR lpNumberStr,
int cchNumber
)
lpLocaleName
Type: LPCWSTR
Pointer to a locale name, or one of the following predefined values.
dwFlags
Type: DWORD
Flags controlling the operation of the function. The application must set this parameter to 0 if lpFormat is not set to NULL. In this case, the function formats the string using user overrides to the default number format for the locale. If lpFormat is set to NULL, the application can specify LOCALE_NOUSEROVERRIDE to format the string using the system default number format for the specified locale.
Caution
Use of LOCALE_NOUSEROVERRIDE is strongly discouraged as it disables user preferences.
lpValue
Type: LPCWSTR
Pointer to a null-terminated string containing the number string to format. This string can only contain the following characters. All other characters are invalid. The function returns an error if the string indicated by lpValue deviates from these rules.
lpFormat
Type: NUMBERFMTW *
Pointer to a NUMBERFMT structure that contains number formatting information, with all members set to appropriate values. If the application does not set this parameter to NULL, the function uses the locale only for formatting information not specified in the structure, for example, the locale string value for the negative sign.
lpNumberStr
Type: Out_writes_opt(cchNumber)LPWSTR
Pointer to a buffer in which this function retrieves the formatted number string. Alternatively, this parameter contains NULL if cchNumber is set to 0. In this case, the function returns the required size for the number string buffer.
cchNumber
Type: int
Size, in characters, for the number string buffer indicated by lpNumberStr. Alternatively, the application can set this parameter to 0. In this case, the function returns the required size for the number string buffer and does not use the lpNumberStr parameter.
Type: int
Returns the number of characters retrieved in the buffer indicated by lpNumberStr if successful. If the cchNumber parameter is set to 0, the function returns the number of characters required to hold the formatted number string, including a terminating null character.
The function returns 0 if it does not succeed. To get extended error information, the application can call GetLastError, which can return one of the following error codes:
Beginning in Windows 8: If your app passes language tags to this function from the Windows.Globalization namespace, it must first convert the tags by calling ResolveLocaleName.
Windows Phone 8: This API is supported.
Header: Declared in winnls.h.
Library: Use kernelx.lib.