G
Guest
I use the following code to convert a managed string to an unmanaged one:
_TCHAR error[255];
const char* umstring = (const char*)Marshal::StringToHGlobalAnsi
(merror).ToPointer();
_tcscpy(error, umstring);
Marshal::FreeHGlobal(IntPtr((void*)umstring));
I can't use StringToHGlobalAuto because it only ever returns the first
character.
I asked why a bit ago, and somebody said you can't use StringToHGlobalAuto
because of something I can't remember, but in any case it doesn't work so
don't say that.
But they also said I need to put my own unicode checking around that, but I
can't see what the point would be - as aren't all managed strings unicode
anyway?
This leads me to believe it must be doing whatever conversions for me I
require anyway.
Is it?
If not, what is the required unicode checking?
_TCHAR error[255];
const char* umstring = (const char*)Marshal::StringToHGlobalAnsi
(merror).ToPointer();
_tcscpy(error, umstring);
Marshal::FreeHGlobal(IntPtr((void*)umstring));
I can't use StringToHGlobalAuto because it only ever returns the first
character.
I asked why a bit ago, and somebody said you can't use StringToHGlobalAuto
because of something I can't remember, but in any case it doesn't work so
don't say that.
But they also said I need to put my own unicode checking around that, but I
can't see what the point would be - as aren't all managed strings unicode
anyway?
This leads me to believe it must be doing whatever conversions for me I
require anyway.
Is it?
If not, what is the required unicode checking?