[Mono-list] Need help with DllImport (P/Invoke) and UCS-4 unicode
lists at cheimes.de
Sun Jul 15 20:57:47 EDT 2007
I'm working on PythonNet (http://pythonnet.sourceforge.net/). PythonNet
is an integration of the C library into .NET which allows a developer to
use .NET code inside Python or Python inside .NET. In the past few weeks
I've fixed a bunch of outstanding bugs and ported PythonNet to Python
2.5. It works pretty well on Windows.
However Linux with mono is a different story. Under Windows Python is
using a UCS-2 to store unicode but most Linux distributions (Debian,
Ubuntu and probably Redhat and SuSE) are compiling Python with UCS-4.
.NET supports only 2 byte unicode. My problem is perfectly explain at
One of the problematic function look like:
[DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "PyUnicodeUCS4_FromUnicode",
ExactSpelling = true, CharSet = CharSet.Unicode)]
internal unsafe static extern IntPtr
PyUnicode_FromUnicode(string s, int size);
More functions can be found at
How should I solve the issue? Has Mono some generic solution for the
general issue of UCS-4 vs. UCS-2 unicode or do I have to convert the
stuff manually by wrapping every external method? If I have to convert
it manually is System.Text.Encoding.UTF32 the right module?
More information about the Mono-list