views:

201

answers:

2

Hi,

Is there a wide character version of WSABUF structure in winsock?

I want to write Japanese data on the socket.

A: 

Probably not. You most likely need to convert your wide character string into some other format, such as UTF7 or something, and send that over the wire then convert back on the other side.

jeffamaphone
that's too bad. looking at Unicode as the future, there should have been something to handle unicode data
Manav Sharma
@Manav: UTF7 and UTF8 _are_ Unicode; they're just not UTF16 (or UCS2).
Roger Lipscombe
+1  A: 

As another answer states, WSABUF uses char * to represent bytes.

TCP provides a stream of bytes it's up to you to decide what those bytes consist of. So, as long as you're providing some kind of protocol framing so that you can read the correct amount of data at the far end, just cast your wide string to a char *.

If you were to follow your question through to its logical conclusion you'd next be asking where the WSABUF that supports PNG images is, or the WSABUF that supports your favourite data structure. It's up to you to translate the data that you have to a stream of bytes (which, in the case of a wide character string, is simply framing and casting).

Len Holgate