Internationalization and localization tools


Locale-Sensitive Windows C++ Function

LPTSTR CharPrev(LPCTSTR lpsz);

LPSTR CharPrevA(LPCSTR lpsz);

LPWSTR CharPrevW(LPCWSTR lpsz);

Internationalization (I18n) Function Overview

The CharPrev function returns a pointer to the previous character in the null-terminated string pointed to by lpsz. If lpsz is pointing at the NULL character, then CharPrev returns lpsz.

The narrow version of the function, CharPrevA, handles single-byte or multibyte character strings, using the system default code page to determine the number of bytes that make up the character.

CharPrevW operates on a wide-character string.

I18n Issues

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

A Windows MBCS application should not use CharPrev unless the language identifier of the application's locale matches that of the System's default locale, i.e. the LANGID value returned from GetSystemDefaultLangID Otherwise, the multibyte code page will not match the application's language and CharPrev will not correctly traverse the multibyte-character string. Consider using CharPrevExA, which allows the multibyte code page to be specified as an argument.

A Windows Unicode application can safely call CharPrev; it will traverse the wide-character string correctly.

Recommended Replacements*

Note that in an MBCS application, CharPrevExA will need to be called explicitly, rather than calling the Generic version CharPrev, since the narrow version of CharPrev is CharPrevA.

*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