Internationalization and localization tools


Locale-Sensitive Windows C++ Function

int FoldString(DWORD dwMapFlags, LPCTSTR lpSrcStr, int cchSrc, LPTSTR lpDestStr, int cchDest);

int FoldStringA(DWORD dwMapFlags, LPCSTR lpSrcStr, int cchSrc, LPSTR lpDestStr, int cchDest);

int FoldStringW(DWORD dwMapFlags, LPCWSTR lpSrcStr, int cchSrc, LPWSTR lpDestStr, int cchDest);

Internationalization (I18n) Function Overview

The FoldString function maps lpSrcStr to lpDestStr, based upon the specified mapping flags passed in dwMapFlags, and returning the number of TCHARs written to lpDestStr, or if the cchDest argument is zero, the number of characters required to hold the mapped string. The return value includes space for the null-terminating character if the lpSrcStr includes a null-terminator and if cchSrc is either -1 or a length that includes the null-terminating character. If there is an error, then the return value is 0 and extended error information can be obtained by calling GetLastError.

cchSrc and cchDest are the size in TCHARs of lpSrcStr and lpDestStr, respectively. If cchSrc is a negative value, then all of the characters in the null-terminated string are transformed.

FoldStringA is the narrow version of the function, passing in single or multibyte strings and length values in bytes.

FoldStringW is the wide version of the function, passing in wide-character strings and the length values in wide characters (WCHARs).

See the MSDN library for more information.

I18n Issues

Use the appropriate version of the function as required for internationalization support, noting the following:

Ensure that cchSrc and cchDest are 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.

FoldString only supports Unicode characters in the range 0xF900 through 0xFFEF. Use the MAP_FOLDCZONE flag to avoid supporting duplicate characters in this range.

Recommended Replacements*

When possible, use the Generic version of the function, rather than the narrow or wide versions, and let the Windows #define UNICODE switch determine which version of the function will be called.

*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