Platform SDK: International Features |
If you use generic data types in your code, it can be compiled for Unicode simply by defining UNICODE before the include statements for the header files. To compile the code for ANSI, omit the UNICODE definition.
To convert code to be compiled for either ANSI or Unicode
cCount = lpEnd - lpStart;
The following expression determines the number of bytes used:
cByteCount = (lpEnd - lpStart) * sizeof(TCHAR);
There is no need to change a statement like the following one, because the pointer increment points to the next character element.
chNext = *++lpText;
while(*lpFileName++ != '\\') { // ... }
Use the TEXT macro as follows in this expression.
while(*lpFileName++ != TEXT('\\')) { // ... }
The TEXT macro causes strings to be evaluated as L"string" when UNICODE is defined, and as "string" otherwise. For easier management, move literal strings into resources, especially if they contain characters outside the ASCII range (that is, 0x00 through 0x7F).
When you compile code that you have changed as outlined above, the compiler creates the same binary file as it did before you made the changes. When you define UNICODE during compilation, however, it is compiled as a Unicode application.