Hi,
I'm using a C DLL in my code which returns an ASCII string value.
Problem is that when i get my string special characters as 'é' or 'è'
or not correctly translated.
I try to use CharSet = CharSet.Auto but it doesn't change anything :( I
try to convert string thanks to Encoding class but it doesn't work too
:(
Thanks,
Vincent.
Here is the Dll Import :
*************************************
[DllImport("cfront.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void DBL_Field_2_Str(System.Text.StringBuilder
_string, int size, int htable, int hrec, int fieldno);
**************************************
Here my function which uses it :
***************************************
System.Text.StringBuilder sTemp = new System.Text.StringBuilder(50);
DBL_Field_2_Str(sTemp,50,htable,hrecord,dteller);
dRow[k] = sTemp;
******************************************
I get the following information in the documentation :
**********************************
Syntax :
void DBL_Field_2_Str(DBL_U8* Str, DBL_S16 StrSize, DBL_HTABLE
hTable, DBL_HREC hRec, DBL_S32 FieldNo);
Str: Variable in which the converted field will be placed
StrSize:Size of Str in bytes, including the terminating zero
hTable: Handle to the table
hRec: Handle to the record containing the field to be converted
FieldNo: Number of the field containing the value to be converted
Remarks :
DBL_Field_2_Str converts the contents of FieldNo in hRec to a
zeroterminated
ASCII string and places it in Str. The field represented by FieldNo
may be of any type.
If Str is too short to hold the converted string, the converted string
is
truncated from the right. If FieldNo is of type integer, large integer
or decimal,
Str is filled with '*' characters.
*************************************
Mattias Sjögren - 15 Jun 2006 18:10 GMT
>I'm using a C DLL in my code which returns an ASCII string value.
>Problem is that when i get my string special characters as 'é' or 'è'
>or not correctly translated.
The ASCII character set doesn't contain any of those characters.
The marshaler will use the default ANSI charset for the returned
string. If that's not appropriate, you'll have to change the parameter
type to a byte array, then manually get a string using the appropriate
System.Text.Encoding.
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.