[Mono-devel-list] pinvoke is passing strings as ansi not unicode

Chad Scholes cscholes at novell.com
Fri Apr 9 14:32:56 EDT 2004


I am trying to call an unmanaged function with an array of strings.  I
was expecting the array of strings to be passed to my unmanaged function
as an array of unicode strings (every other byte is 0) but I am getting
ansi strings (every byte is an ansi character).  

Here are my function definitions:

Managed function:
[DllImport("nsrchcsw", CharSet=CharSet.Unicode,
CallingConvention=CallingConvention.Cdecl)]

public static extern int nativeQuery(

	long				config_address,

	int				num_queries,
	[MarshalAs(UnmanagedType.LPArray,ArraySubType=UnmanagedType.LPWStr)]
	string[]			query_list)

and the unmanaged function:
extern "C" HRESULT nativeQuery(

		WS_FUNCTION_PTR  config_address,

		QF_INT32		num_queries,

		QF_UNICODECHAR	**query_list)

where WS_FUNCTION_PTR is a long long, QF_INT32 is a 32 bit int, and
QF_UNICODECHAR is an unsigned short.  I have tried assigning
QF_UNICODECHAR to wchar_t but that didn't change. 

Is it actually passing the parameters as UTF-8 and not double-byte
UNICODE?

any ideas?

I am using mono version .31.

Thanks,
Chad Scholes
Novell, Inc







More information about the Mono-devel-list mailing list