[Mono-dev] Marshalling of strings

Miguel de Icaza miguel at ximian.com
Thu Sep 22 14:25:15 EDT 2005


Hello,

> Hows marshalling of strings to native functions work in Mono and .NET in 
> general?
> 
> I can set the character set when creating a pinvoke, but only to ANSI or 
> Unicode.
> 
> What does ANSI mean? I thought ANSI was a family of character sets?

In Mono we do not use ANSI, but we overload it to be UTF-8.

> What does Unicode mean exactly? UTF-16? UTF-32? What about endianess?

UTF-16.

> What if my function uses UTF-7? I mean that's still Unicode but I bet 
> Mono isn't expecting my function to return it.

For anything else, you must write either a custom marshaller, or do the
encoding yourself, and pass an IntPtr to the encoded value, and decode
the return values.

> What if my strings aren't null terminated? They're still Unicode if 
> they're not null terminated.

You must handle them manually as well.

Miguel.



More information about the Mono-devel-list mailing list