|
AN
The Charset.None value is obsolete and should not be used. It currently has the same behavior as CharSet.Ansi. Like many things, we really wanted to remove it before we shipped v1.0, but with so many dependencies on our APIs it was too risky.
AN
It's somewhat unfortunate that CharSet.Ansi is the default behavior for PInvoke, since managed strings and characters are internally Unicode. Win32 APIs often expose both an ANSI and Unicode export, but by default you end up calling the ANSI one, requiring the Interop marshaler to copy each Unicode string to a new ANSI string! In contrast, by calling the Unicode export, the CLR can just pin the managed strings and expose them directly. You can override the default behavior and explicitly mark each PInvoke signature with CharSet.Auto, although in the future the CLR will provide a module-level DefaultCharSetAttribute that allows you to select your own default for all signatures in your module. |