[Mono-dev] PtrToStringAnsi

Joshua Tauberer tauberer at for.net
Wed Mar 8 14:30:33 EST 2006

While debugging a SqliteClient issue, I came across an interesting bug.
 The following returns null when I'm pretty sure it should not (it
doesn't on Windows):


In case the encoding of this email gets messed up, that's a u with
umlauts, (char)0xFC.

The encoding half "works" (Marshal.ReadByte reports the bytes (0xFC
0x00)), on the assumption that I'm supposed to get ANSI out of this
method.  Internally, g_utf16_to_utf8 is used, which means that (besides
being surprised this call doesn't actually do ANSI encoding) I would
actually expect a multibyte representation of that character.  That's
from a few minutes of Googling for info on UTF-8.

So I'm confused.  Can someone with more knowledge about encodings tell
me whether this really doesn't make sense?

I'm using the latest RPMs.  Here's a test program:

using System;
using System.Runtime.InteropServices;

public class Test {
    public static void Main() 		

- Joshua Tauberer


"Unfortunately, we're having this discussion. It's too bad,
because guess who listens to the discussion: the enemy."

More information about the Mono-devel-list mailing list