Locale-Sensitive Windows C++ Functions
int wnsprintf(LPTSTR lpOut, int cchLimitIn, LPCTSTR pszFmt, ...);
int wnsprintfA(LPSTR lpOut, int cchLimitIn, LPCSTR pszFmt, ...);
int wnsprintfW(LPWSTR lpOut, int cchLimitIn, LPCWSTR pszFmt, ...);
Internationalization (I18n) Function Overview
The wnsprintf function is a Microsoft Windows version of sprintf.
It writes output to lpOut under control of
the pszFmt format argument. A null character is placed at the end of the string and the number of
characters written is returned, or a negative value if an error occurs. cchLimitIn is the maximum number of characters written to lpOut .
Note that wnsprintf does not support floating point or pointer types, and
supports only the left alignment flag.
wnsprintfA is the narrow version of the function; its arguments are single-byte or multibyte strings, and cchLimitIn is a byte size.
wnsprintfW is the wide version of the function; its arguments are wide-character strings, and cchLimitIn is a wide-character size.
See the MSDN Library
for more information.
I18n Issues
Use the appropriate version of the function as required for internationalization support,
ensuring that cchLimitIn 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.
Where locale-dependent numeric formatting is required, use the locale-sensitive
GetNumberFormat function to first format numbers and then
insert them as strings, rather than using the %d or %i format options,
which are locale-independent.
See String Formatting in C and C++ for a discussion on locale-sensitive formatting in internationalized applications.
Recommended Replacements*
Due to the security risks of this function, consider using a safe string function.
If wnsprintf is called, use the Generic version of the function rather than explicitly calling the narrow or wide versions. wnsprintf
will be mapped to wnsprintfW when the program is compiled with the #define UNICODE switch, and to wnsprintfA otherwise.
Using the Generic version facilitates switching between an MBCS and UTF-16 Unicode application.
These are shown as the first choices in the following table:
*If you're already using the recommended function, see I18n Issues for other reasons why Globalyzer is detecting the function.
|