Internationalization and localization tools


Locale-Sensitive Windows C++ Methods

Internationalization (I18n) Discussion:

This category of Windows methods are locale-sensitive, using the application's locale to format, sort, or convert text strings. They are based on the Windows Generic TCHAR data type, supporting multibyte strings when the _MBCS compiler symbol is defined, and wide-character strings when the _UNICODE symbol is defined.

In addition, the methods will often call a Windows Generic function, which will then map to the underlying MBCS or Unicode function as directed by the compiler flag. For example, the following table shows the MBCS/Unicode mapping for a few locale-sensitive CString methods.

CString Method MBCS Function Unicode Function
Compare _mbscmp wcscmp
CompareNoCase _mbsicmp _wcsicmp
Collate _mbscoll wcscoll

The methods listed below belong to various C++ classes, such as CString, COleDateTime, CTime, and CTimeSpan. To use correctly, ensure that the locale is set correctly, by calling setlocale/_wsetlocale/_tsetlocale. In addition, on a Windows MBCS platform, call _setmbcp to set the multibyte code page.

Although the class methods will operate correctly on multibyte strings (when the _MBCS compiler flag is set), care must still be taken to ensure that multibyte strings are parsed correctly. For example, in the case of the CString class operating on multibyte strings; the class methods will count, return, and manipulate strings based on 8-bit characters, requiring the application to interpret MBCS lead and trail bytes as needed.

Click on a method for more information:

Collate

CollateNoCase

Compare

CompareNoCase

Format

FormatV

MakeLower

MakeUpper

ParseDateTime

 

 Locale-Sensitive C++ Methods

 

Lingoport internationalization and localization services and software