[Mono-list] What is Correct way to marshal wchar_t ?
ptrajkumar at gmail.com
Wed Jun 3 12:54:08 EDT 2009
I am trying to marshal strings from managed code to native code using
DllImport. Marshalling both wchar_t* and char* works under mono on a windows
But on mac os x wchart_t marshalling does not seem to work. The wchar_t* is
all junk. I have tried to search this forum and people have talked about it
and it seems to have been fixed.
Am I missing something ? I have experimented with CharSet.Unicode on
DllImport and it still doesnt work ?
What is the recommended way ?
My cs files is something like this
[DllImport("Test.dll", EntryPoint = "Global_PrintStringW")]
public static extern void Global_PrintStringW(
[DllImport("Test.dll", EntryPoint = "Global_PrintStringA")]
public static extern void Global_PrintStringA(string arg1);
private static void StringMarshallingTest()
string newString = "This is a cool string";
Console.WriteLine("Global_PrintStringA Test ");
Console.WriteLine("Global_PrintStringW Test ");
My cpp file is something like this
EXPORT_API void Global_PrintStringW(const wchar_t * str)
std::wcout << "Global_PrintStringW called with " << str << std::endl;
EXPORT_API void Global_PrintStringA(const char* str)
std::wcout << "Global_PrintStringA called with " << str << std::endl;
View this message in context: http://www.nabble.com/What-is-Correct-way-to-marshal-wchar_t---tp23855173p23855173.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list