[Mono-bugs] [Bug 77746][Wis] New - StringToCoTaskMemAnsi uses
Latin1 rather than UTF-8 encoding
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Thu Mar 9 13:07:22 EST 2006
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 tauberer at for.net.
http://bugzilla.ximian.com/show_bug.cgi?id=77746
--- shadow/77746 2006-03-09 13:07:22.000000000 -0500
+++ shadow/77746.tmp.1710 2006-03-09 13:07:22.000000000 -0500
@@ -0,0 +1,39 @@
+Bug#: 77746
+Product: Mono: Class Libraries
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: tauberer at for.net
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: StringToCoTaskMemAnsi uses Latin1 rather than UTF-8 encoding
+
+System.Runtime.InteropServices.Marshal.StringToCoTaskMemAnsi uses Latin1
+encoding rather than UTF-8. It should wrap StringToHGlobalAnsi, which does
+the right thing, except that on Windows it should then copy the result into
+a CoTaskMem-allocated buffer.
+
+Here's a test case. The first line prints null because the encoding can't
+be undone. It should print a u-with-umlauts. The second line prints 0xFC,
+which is the ANSI code for the character. It should print something else,
+the start of a UTF-8 two-byte encoding of the character.
+
+using System;
+using System.Runtime.InteropServices;
+
+public class Test {
+ public static void Main() {
+ string u = ((char)0xFC).ToString();
+ Console.WriteLine(Marshal.PtrToStringAnsi(Marshal.StringToCoTaskMemAnsi(u)));
+
+Console.WriteLine(Marshal.ReadByte(Marshal.StringToHGlobalAnsi(u)).ToString("x"));
+ }
+}
More information about the mono-bugs
mailing list