Reputation: 93
I am developing a C# Server and a C++ Client. The C++ client sends some unicode strings to the server. This is OK. I have a string object and use the data() function to get the byte array and send it over the socket to the c# server. This is all ok. The server receives the message correctly. The problem is with the receiving. I receive the bytes from the c# server however I want a way to "convert" the bytes to the corresponding unicode string.
I tried to create a wide string object:
wstring str = wstring((wchar_t *) buff);
and extract the string via the c_str() function but the result string is not the string the server sends!!
Where the buff is a byte array(unsigned char array) which I receive from the socket.
Any help would be appreciated!!!
Upvotes: 1
Views: 2558
Reputation: 7586
Here's how I would go about trying to solve this problem:
Start with a known entity (data being sent from the server) and check it every step of the way to see where it stops being what you expect it to be. This will tell you where your error is. Once you know that, if you are still having problems, post detailed information about the spot with the error.
Upvotes: 3