"Craig Johnston" <Cr***********@discussions.microsoft.comha scritto nel
messaggio news:DF**********************************@microsof t.com...
>I am in the process of converting an application to Unicode that is built
with Visual C++ .NET 2003.
You can go to your project Properties (right click on the project name, and
select "Properties").
Then, in "General" group, go to "Character Set" and choose the option "Use
Unicode Character Set".
instead. I have defined the _UNICODE constant in the project Properties
and
You should define both _UNICODE and UNICODE (however, this is done by the
IDE if you change the configuration as shown above).
If you move to Unicode, you should pay attention in your code, e.g. in
places where you used 'char', you should use TCHAR (than is OK for both ANSI
and Unicode), or wchar_t (for Unicode-only).
Or if you have some string buffers and you have to specify the buffer
length, this length is usually in TCHARs, which is the same of length in
bytes only for ANSI, but *not* for Unicode (for Unicode, you must divide the
total length in bytes by the bytes in a TCHAR, i.e. 2).
So considering the following code:
// Assume DoSomething has a prototype like so:
//
// void DoSomething( LPTSTR bufferPtr, size_t bufferCch );
//
char buffer[200];
DoSomething( buffer, sizeof(buffer) );
If you port to Unicode, you should use:
TCHAR buffer[200];
DoSomething( buffer, sizeof(buffer) / sizeof(buffer[0]) );
(There must be something like _countof() to do the
sizeof(array)/sizeof(array[0]) calculation.)
Giovanni