[Mono-bugs] [Bug 56965][Maj] Changed - P/Invoke is marshalling string arrays as UTF-8 not Unicode

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 16 Apr 2004 15:02:03 -0400 (EDT)

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by cscholes@novell.com.


--- shadow/56965	2004-04-14 16:39:49.000000000 -0400
+++ shadow/56965.tmp.8368	2004-04-16 15:02:03.000000000 -0400
@@ -1,13 +1,13 @@
 Bug#: 56965
 Product: Mono: Runtime
 Version: unspecified
 OS: SUSE 9.0
 OS Details: Also happens on Windows XP
-Status: RESOLVED   
-Resolution: FIXED
+Status: REOPENED   
 Severity: Unknown
 Priority: Major
 Component: misc
 AssignedTo: vargaz@freemail.hu                            
 ReportedBy: cscholes@novell.com               
 QAContact: mono-bugs@ximian.com
@@ -62,6 +62,36 @@
 ------- Additional Comments From miguel@ximian.com  2004-04-14 00:51 -------
 Remove "hidden" from the bug, so it becomes public.
 ------- Additional Comments From vargaz@freemail.hu  2004-04-14 16:39 -------
 Fixed in CVS.
+------- Additional Comments From cscholes@novell.com  2004-04-16 15:02 -------
+The original bug is fixed: My array of strings is being passed as
+unicode.  However, I have another array of strings that I would like
+to pass as ansi.  So I have defined it like:
+[DllImport("nsrchcsw", CharSet = CharSet.Unicode, CallingConvention =
+public static extern void nativeQFIndexerCreateIndex(long nsAddress,
+[MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr)] 
+string[] cmdArray, int count);
+It is now always passing it as Unicode.  Should I beable to define the
+marshalling in this way?  I can work around this: I will just convert
+the Unicode to ansi in my unmanaged code.
+One other problem. Which I think is the same problem just in the other
+direction.  I now have unmanaged code that is calling a delegated
+function in my managed code. I am sending unicode strings (defined as
+unsigned short* string - this is not an array of strings in this
+case).  Once the string is passed to my managed code it is truncated
+to the first character.
+The bytes in my unmanaged code look like: t,0,i,0,t,0,l,0,e,0,0,0
+I get t,0 in my managed code.
+Is it thinking the strings are UTF-8 not Unicode?