I was wondering if anybody could advise me on unicode issues
I have an application which consists of a C# program, that calls a
unmanaged C++ DLL
The details are as follows
Environment: MSVS.NET 2k3, WinXP Pr
Unmanaged C++ DLL
_UNICODE defined
Uses _TCHAR* for strings, and _tcs~ functions for string manipulation
Uses _T("textconst") for text constants
mixed debugging mode (to allow stepping into it
Managed C# program
Consists of one winforms control and one winforms project
both have the same debug settings (allow unmanaged debugging)
The DllImport interface to the C++ DLL calls it using [CharSet = CharSet.Auto
and the string parameter is passed wit
[MarshalAs(UnmanagedType.LPTStr)]

From what it says in the documentation, it seems that by using UnmanagedType.LPTSt
in the DllImport section, the operating system will decide automatically whether t
marshal the string arguments as unicode or not. This is great if I just want my progra
to work, but not if I want to understand what is going on with all this unicode stuff

If somebody can try and understand the following questions and lend a hand t
clear my understanding I'd be very grateful

Will the .NET framework's interop marshal the C# calls to the DLL as unicode because the DL
is unicode, or will it be because the operating system is XP

On, say, a Win98 OS, which of the following are true
- the DLL wouldn't compile unless unicode was turned of
- the DLL would compile if unicode was kept on, but would produce garbage
- the program (as compiled on XP with unicode on) wouldn't ru
- the program (as compiled on XP with unicode on) would run, but characters 128-255 wouldn't be available

On a computer with, say, NT/2000/XP OS, which of the following are true
- the program (as compiled on XP with unicode on) would be faster than if unicode was of
- the program (specifically the DLL) wouldn't be able to process characters 128-255 i
unicode was turned off

When I say 'if unicode was turned off' I mean the setting to switch the _UNICODE fla
off correctly set in the compiler properties before compiling the DLL
I notice that when I do this, sizeof(_TCHAR) = 1 and when it's on, sizeof(_TCHAR) is 2
I understand this (almost). But I'm lost when it comes to differences between different OSes
And why do unicode characters take 2 bytes, when 1 - 255 can be fit in one

Thank