1

I recently got a requirement to develop a chat-like application, or rather, a foundation of classes and methods that would allow certain applications to have chat-like features. The framework must be usable in at least two languages: Visual Basic 6 and C#.

If VB6-Application A were to transmit string data to CSharp-Application B, when the data is received by CSharp-Application B and placed into a string, can I assume the string will contain the same information it contained when VB6-Application A sent it? (i.e. it will contain the same sequence of bytes that was sent from the original string instance in the VB6 app.)

1
  • 3
    Depends entirely on A) what encoding it expects to send/receive and B) what encoding it transforms the received message/message to send. Aside from this, there shouldn't be any changes in the byte-per-byte information sent.
    – Neil
    Commented Sep 8, 2014 at 16:25

1 Answer 1

1

Echoing @Neil's comment, you have to make sure the encoding is the same on the sending/receiving ends. Assuming that you can pass a byte array from one language to the other, you will want to think about what encoding to use. UTF-8 is likely the most popular now. If you're not familiar with character encodings, please take a brief moment to check out the basics, courtesy of Joel Spolsky.

Doing a little research, it sounds like VB6 stores strings internally as UTF-16 but tends to convert to ANSI for the outside world. So an approach you could take on the VB side for conversions between UTF-8 and byte arrays is found here. The C# side is a little less convoluted and you can find an MSDN page with nice code samples here.

1
  • I had to put this requirement on hold for a while. I will be working on it now, and the first and second articles were very very instructive. Thanks!
    – ferc
    Commented Sep 22, 2014 at 23:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.