title: How do I send wide characters using winsock's send() function?
body: <p>It says <a href="http://msdn.microsoft.com/en-us/library/ms740149%28VS.85%29.aspx" rel="nofollow">here</a> that the send function expects const char*. </p>
  
  <p>How do I send wide characters? I tried the following:</p>
  
  <pre><code>void MyClass::socksend(const wchar_t* wbuffer) {
     int i;
     char *buffer = (char *)malloc( MB_CUR_MAX );
     wctomb_s(&amp;i,buffer, MB_CUR_MAX, (wchar_t)wbuffer);
     int buflen = strlen(buffer) + 2;
     char sendbuf[DEFAULT_BUFLEN];
     strcpy_s(sendbuf,buflen,buffer);
     sendbuf[buflen - 1] = '\n';
     int senderror = send(this-&gt;m_socket, sendbuf, buflen, 0);
     // error handling, etc goes here...
  
  }
  </code></pre>
  
  <p>This doesn't do what I expect it to. It doesn't seem to be sending anything to the socket. How do I fix this?</p>