Re: Proposal to extend documentation about interop
From: Robert Jordan (robertj_at_gmx.net)
Date: 10/19/04
- Next message: Mattias Sjögren: "Re: FindNextPrinterChangeNotification() problem"
- Previous message: CEP921: "Re: How to execute unmanaged exe from .net application..."
- In reply to: John Allberg: "Proposal to extend documentation about interop"
- Next in thread: John Allberg: "Re: Proposal to extend documentation about interop"
- Reply: John Allberg: "Re: Proposal to extend documentation about interop"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 20 Oct 2004 00:19:58 +0200
John Allberg wrote:
> Hi!
>
> I think the MSDN docs about interop doesn't state clearly enough that there
> is a character encoding conversion automaticly done from Unicode to the
> characterset for the computer during interop.
>
> This got me really puzzled for a few days.
>
> I've got a legacy C-application (dll) that takes in UTF-8 encoded strings in
> an array of structs. I call that C-dll from C# which works fine, as long as
> I use ansi characters, for example english. When sending in swedish
> characters (where the utf-8 encoding becomes two bytes) such as åäö the
> lowercase works fine, but the uppercase ÅÄÖ simply comes out as invalid
> utf-8 encoding of the character FF.
>
> I solved it by doing the conversion of UTF-8 to bytes and when going back to
> string used the encoder for "Default" and converting those bytes to a
> "unicode-string". That way, when the interop converts the string from
> Unicode to "Default", the UTF-8 once again surfaces.
>
> So my suggestion is to update the MSDN doc to state this conversion clearly
> enough.
The automatic p/invoke conversion can be applied only to those
legacy types:
- LPSTR (ansi encoding, 1 byte)
- LPWSTR (unicode encoding. 2 bytes)
- LPTSTR (platform specific, one of the above)
- BSTR
You cannot properly import UTF-8 because Win32 doesn't support
UTF-8 for the legacy API either.
bye
Rob
- Next message: Mattias Sjögren: "Re: FindNextPrinterChangeNotification() problem"
- Previous message: CEP921: "Re: How to execute unmanaged exe from .net application..."
- In reply to: John Allberg: "Proposal to extend documentation about interop"
- Next in thread: John Allberg: "Re: Proposal to extend documentation about interop"
- Reply: John Allberg: "Re: Proposal to extend documentation about interop"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|