Internationalization and localization tools


Locale-Sensitive Windows C++ Function

BOOL IsCharAlphaNumeric(TCHAR ch);

BOOL IsCharAlphaNumericA(CHAR ch);

BOOL IsCharAlphaNumericW(WCHAR ch);

Internationalization (I18n) Function Overview

The IsCharAlphaNumeric function returns a non-zero value if the character ch is an alphabetic or numeric character. This determination may be based on the semantics of the language selected by the user during setup or through the Control Panel. In the event of an error, or if the character is not alphanumeric, 0 is returned and extended error information can be obtained by calling GetLastError.

IsCharAlphaNumericA is the narrow version of the function, passing in a single or multibyte character.

IsCharAlphaNumericW is the wide version of the function, passing in a wide character.

I18n Issues

In an internationalized application, IsCharAlphaNumeric should not be used for the following reasons:

An application that is compiled with the MBCS compiler flag will use the user's default language setting to test the semantics of the character. This is undesirable in an internationalized application, where the required language may vary and is independent of the system's settings.

Although an application that is compiled with the UNICODE compiler flag and running on a later version of Windows (WinNT/2K/XP) will obtain correct results when calling IsCharAlphaNumeric on a Unicode character, there will still be a problem when running on Win95/98/ME platforms. This is because, similar to an MBCS application, the Microsoft Layer for Unicode, which allows a Unicode application to run on these non-Unicode platforms, will use the system's language rather than the program's language.

To work in both MBCS and Unicode UTF-16 environments, consider using a combination of _istalpha and _istdigit, which use the program's settings when needed.

Recommended Replacements*

As mentioned above, IsCharAlphaNumeric is not recommended. However, if it is to be used, call 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