Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / June 2006

Tip: Looking for answers? Try searching our database.

ASCII string problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Vincent.Arod@gmail.com - 15 Jun 2006 07:35 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.