Internationalization and localization tools


Locale-Sensitive Windows C++ Function

LPTSTR lstrcpyn(LPTSTR lpString1, LPTSTR lpString2, int iMaxLength);

LPSTR lstrcpynA(LPSTR lpString1, LPSTR lpString2, int iMaxLength);

LPWSTR lstrcpynW(LPWSTR lpString1, LPWSTR lpString2, int iMaxLength);

Internationalization (I18n) Function Overview

The lstrcpyn function copies, at most iMaxLength characters from 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.

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

lstrcpynW 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 iMaxLength is correct 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*

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

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