Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: mDNSResponder DLL.NET doesn't marshal strings correctly



Robert,
CharSet property of DllImport attribute does not support UTF8 marshalling.
CharSet.Unicode marshalling is used to call DLL functions that expect
LPCWSTR or LPWSTR.
dns_sd functions expect 0-terminated sequences of bytes, not wchar_t's.
After fixing string marshalling, I tested the dnssd.net.dll
by registering a service named "Hello \u65a9 World!". It showed up correctly
in Safari Rendezvous browser and in my Windows test app with the *same*
glyph. Before the fix, I was getting just an empty square character.

When I toyed with writing a dnssd.dll wrapper in C#, I had to write a custom
marshaller to successfully pass strings from C# code to dns_sd and back.
See MarshalAs attribute documentation.

-----Original Message-----
From: Robert MacGregor
To: Pavel Repin; 'email@hidden'
Sent: 7/19/04 6:12 AM
Subject: Re: mDNSResponder DLL.NET doesn't marshal strings correctly

Pavel,

.NET provides an attribute called CharSet to indicate marshalling  
behaviour. Default behaviour for C++ is CharSet.None, equivalent to  
CharSet.ANSI :-(. Specifying CharSet.Unicode should get the Unicode  
strings without having to code the marshalling yourself. CharSet  
applies to the name of the called DLL functions and string parameters  
passed to those functions.
_______________________________________________
rendezvous mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/rendezvous
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.