[Mono-list] Trouble with utf-16 marshaling

Robert Jordan robertj at gmx.net
Fri Jun 29 22:02:17 EDT 2007


Hi Dan,

Maser, Dan wrote:

Here are you speaking about "out" marshaling:

>    It works properly in windows with MS .NET, but doesn't work for me in
> linux with mono.   I've verified in gdb that the C library is returning
> the correct string, but immediately after the C dll returns and mono
> does the LPWStr marshaling the string is total garbage characters.   I
> am under the impression from previous posts that 2-byte UTF-16 should
> marshal properly to mono with the LPWStr attribute.  In fact it looks
> like some of the gdiplus calls use that same thing and work... any ideas
> what I can check on because mine doesn't?

But your sample is about "in" marshaling:

> 
>    For more clarification my C library has a function signature like
> this:
> 
> void my_function(unsigned short* myArg);
> 
>     And my C# code looks like this:
> 
> 
> [DllImport("myCLib")]
> public static extern void my_function([MarshalAs(UnmanagedType.LPWStr)]
> string myArg);

Please post, or better: file a bug with a self-contained and
compilable sample.

Robert



More information about the Mono-list mailing list