[Mono-bugs] [Bug 40149][Min] New - DllImport CharSet=CharSet.Unicode has no effect

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Sat, 22 Mar 2003 03:40:49 -0500 (EST)


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 lmaloney@bigpond.net.au.

http://bugzilla.ximian.com/show_bug.cgi?id=40149

--- shadow/40149	Sat Mar 22 03:40:49 2003
+++ shadow/40149.tmp.31191	Sat Mar 22 03:40:49 2003
@@ -0,0 +1,65 @@
+Bug#: 40149
+Product: Mono/Runtime
+Version: unspecified
+OS: GNU/Linux [Other]
+OS Details: Linux 2.4.17 mono CVS Mar 22 2003
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: lmaloney@bigpond.net.au               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: DllImport CharSet=CharSet.Unicode has no effect
+
+Description of Problem:
+When setting a string parameter for a DllImport function to be marshalled
+as unicode, the string is not converted to unicode.
+
+Steps to reproduce the problem:
+
+Dump.cs:
+using System.Runtime.InteropServices;
+
+public class DumpTest
+{
+	[DllImport("dump.dll", CharSet=CharSet.Unicode)]
+	private static extern void HexDump(string data);
+
+	public static void Main()
+	{
+		HexDump("First test");
+	}
+}
+
+dump.c -> libdump.dll.so / dump.dll:
+void HexDump(char *data)
+{
+	int i;
+	char *p;
+
+	p = data;
+	for (i=0; i < 8; ++i)
+	{
+		printf("%0x ", (int) *(p++));
+	}
+	putchar('\n');
+}
+
+Actual Results:
+46 69 72 73 74 20 74 65
+
+Expected Results: (Observed in Windows/Microsoft .NET)
+46 0 69 0 72 0 73 0
+
+How often does this happen? 
+Always
+
+Additional Information:
+
+This bug also occurs when Dump.exe is compiled with mcs and run in MS .NET.
+ This is probably a separate, mcs related problem.