[Mono-list] Need help with DllImport (P/Invoke) and UCS-4 unicode
joncham at gmail.com
Sun Jul 15 22:24:40 EDT 2007
I had the same problem in a different setting. I use a custom
marshaller (http://msdn2.microsoft.com/en-us/library/d3cxf9f0.aspx) for
strings in all of my pinvokes. It's pretty straightforward setting up a
custom marshaller if you follow the link above. If you need more details let
On 7/15/07, Christian Heimes <lists at cheimes.de> wrote:
> 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?
> Mono-list maillist - Mono-list at lists.ximian.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-list