[Mono-dev] Specifying MarshallAs for [Out] StringBuilder

Debajyoti Bera dbera.web at gmail.com
Sun Mar 23 09:59:18 EDT 2008


Hi,
	I have a native method that I P/Invoke which returns a string. I use an [Out] 
StringBuilder to get that returned string in my managed code. But the native 
method returns the string in platform encoding and not utf8 and when the 
P/Invoke returns, the StringBuilder is empty !
	I read somewhere that by default mono marshalls and unmarshalls strings as 
utf8 so this is not surprising. I have been able to pass strings to another 
method which requires platform encoding by manually marshalling it, as shown 
in the MONO FAQ (using UnixMarshal.StringToHeap).
	But how I do manually unmarshall a StringBuilder ? I tried using Charset.Auto 
and MarshalAs(LPTStr) - that did not help.

Thanks,
- dBera

-- 
-----------------------------------------------------
Debajyoti Bera @ http://dtecht.blogspot.com
beagle / KDE / Mandriva / Inspiron-1100


More information about the Mono-devel-list mailing list