Internationalization and localization tools


Locale-Sensitive Windows C++ Functions

int wvsprintf(LPTSTR lpOutput, LPCTSTR lpFmt, va_list arglist);

int wvsprintfA(LPSTR lpOutput, LPCSTR lpFmt, va_list arglist);

int wvsprintfW(LPWSTR lpOutput, LPCWSTR lpFmt, va_list arglist);

Internationalization (I18n) Function Overview

The wvsprintf function writes output to lpOutput under control of the lpFmt format argument. A null character is placed at the end of the string and the number of characters written is returned, or a value less than the length of the expected output if an error occurs.

wvsprintfA is the narrow version of the function; its arguments are single-byte or multibyte strings, and its return is a byte value.

wvsprintfW is the wide version of the function; its arguments are wide-character strings, and its return is a wide-character value.

See the MSDN Library for additional information.

I18n Issues

Use the appropriate version of the function as required for internationalization support, ensuring that lpOutput is large enough for the chosen platform: it will hold 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 wvsprintf is called, use the Generic version of the function rather than explicitly calling the narrow or wide versions. wvsprintf will be mapped to wvsprintfW when the program is compiled with the #define UNICODE switch, and to wvsprintfA 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.

Locale-Sensitive Windows C++ Functions

 

Lingoport internationalization and localization services and software