Jump to content
  • Advertisement
Sign in to follow this  

Encoding problem with string C# from C++ DLL

This topic is 3817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, VS 2008 3.5.Net I am getting a string from a call back in a C++ native DLL which I have written. And for some reason it displays wrong something like this. i.e. [][[[[[[[[[[[[[ or ????????????????? with ASCII encoding. My code is below. I think the DLL is using unicode, and I am trying to encode it in ASCII. The parameter in call back definition is char*. And in my C# I am using a string. I have also tried Unicode, UTF-8, and ASCII. All of them display incorrectly. Am I doing something wrong with my code? Many thanks for any suggestions, *.hpp file ============== typedef int (__stdcall *ptrIncomingCall)(int callID, char *caller); MOBILEDLL_API int drvIncomingCall(ptrIncomingCall cb); *.cpp file ============== int drvIncomingCall(ptrIncomingCall cb) { int callerID = cb(20, "Joe bloggs"); return callerID; } C# code =============== private delegate int incomingCallDelegate(int callerID, string caller); [DllImport("MobileDLL.dll")] static extern int drvIncomingCall(incomingCallDelegate cb); int OnIncomingCall(int callerID, string caller) { this.label1.Text = callerID.ToString(); this.label2.Text = caller; return 1; } private void button4_Click(object sender, EventArgs e) { drvIncomingCall((incomingCallDelegate)OnIncomingCall); }

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!