[Mono-list] Need help with DllImport (P/Invoke) and UCS-4 unicode

Christian Heimes lists at cheimes.de
Tue Jul 17 11:28:11 EDT 2007


Miguel de Icaza wrote:
> Sadly, you have to do it manually.
> 
> We brought this up a few times at ECMA and three or four times with
> different people at Microsoft and we did not get very far.     The
> solution is trivial, and we could implement it in Mono (expand the
> CharSet definition to include UTF8, UCS4 explicit encodings), but it
> would not be compatible with .NET, so we decided against doing it.

It's a shame that a product which is advertised cross platform
compatible doesn't implement or at least provide support for important
standards. IIRC Charset.Unicode is equal to Little Endian UCS-2. Charset
does neither take UTF-8 and UCS-4 nor Big Endian into account. :(

With the incredible help from both Jonathans I was able to adapt the
code to UCS-4. The custom marshaler for input works like a charm and I'm
going to test the output marshaling later.

Somebody should add some sample code to
http://www.mono-project.com/Interop_with_Native_Libraries#P.2FInvoke_Specification
for the next poor developers.

By the way Mono works better than I had expected. I got PythonNet pretty
much running. I run into some problems with ref counting (Mono seems to
be more sensitive to bugs than .NET) and two unit tests related to
overloading and generics aren't passing but the rest works. Well done!

Christian



More information about the Mono-list mailing list