Internationalization and localization tools


Locale-Sensitive Windows C++ Function

LPTSTR lstrcpy(LPTSTR lpString1, LPTSTR lpString2);

LPSTR lstrcpyA(LPSTR lpString1, LPSTR lpString2);

LPWSTR lstrcpyW(LPWSTR lpString1, LPWSTR lpString2);

Internationalization (I18n) Function Overview

The lstrcpy function copies the string at lpString2 to the buffer pointed to by lpString1, including the terminating null-character. A pointer to lpString1 is returned if the copy is successful; NULL is returned in the event of an error.

lstrcpyA is the narrow version of the function; whose arguments and return are single-byte or multibyte strings.

lstrcpyW is the wide version of the function; with wide-character string arguments and return.

I18n Issues

Use the appropriate version of the function as required for internationalization support, ensuring that lpString1 is large enough to hold lpString2 and the terminating null character for the chosen platform. See Locale-Sensitive Length Functions for a discussion on multibyte and wide character sizes.

Recommended Replacements*

Due to the security risks of this function, consider using a safe string function.

If lstrcpy is called, use the Generic version of the function rather than explicitly calling the narrow or wide versions. lstrcpy will be mapped to lstrcpyW when the program is compiled with the #define UNICODE switch, and to lstrcpyA 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