[Mono-dev] Marshalling of strings

Chris Seaton chris at chrisseaton.com
Tue Sep 20 19:16:09 EDT 2005


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?

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

If I write a native function that uses UTF-8, I should set the CharSet 
to be Unicode, but then how does it know that it's UTF-8 and not 
anything else? Does it sniff the bytes?

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.

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

Can someone tell me explicitly what character encodings should be used 
to do pinvoke?

Thanks

Chris Seaton



More information about the Mono-devel-list mailing list