All 16-bit applications use ANSI strings. 32-bit applications may use either ANSI or Unicode strings. ANSI applications store strings as unsigned char, each byte containing a different character. Unicode applications store strings as unsigned short, each short integer value containing a different character.
To specify ANSI, declare the following in your project settings:
#define OLE2ANSI
To specify Unicode, declare the following in your project settings:
#define _UNICODE
The advantage of using Unicode in your applications is that it enables you to easily localize your application into languages such as Chinese, where two bytes are required to store characters. ANSI applications require special DBCS (Double Byte Character Set) functions in order to be localized into languages such as Chinese.
The advantage of using ANSI strings is that, in Microsoft Windows 95, the Windows system calls take ANSI strings; therefore, you must convert Unicode strings to ANSI before calling into these functions.
You can compile your application in ANSI or Unicode by using the _T() macro. _T is defined by Microsoft Visual C++ and is used to wrap all string literals. In ANSI, this macro is a no-op. In Unicode, it appends the L keyword to inform the compiler that the literal is to be read in as Unicode. For example:
void OpenADatabase()
{
CdbDBEngine dben;
CdbDatabase db;
db = dben.OpenDatabase(_T("MyDB.MDB"));
}
The above code will compile for both ANSI and Unicode applications.