title: Qt - Converting QString to Unicode QByteArray
body: <p>I have a client-server application where client will be in Qt(Ubuntu) and server will be C#. Qt client willsend the strings in UTF-16 encoded format. 
  I have used the QTextCodec class to convert to UTF-16. But whenever the conversion happens it will be padded with some more characters. For example</p>
  
  <p>"&lt;bind endpoint='2_3'/&gt;"</p>
  
  <p>will be changed to </p>
  
  <p>"\ff\fe&lt;\0b\0i\0n\0d\0 \0e\0n\0d\0p\0o\0i\0n\0t\0=\0'\02\0_\03\0'\0/\0>\0\0\0"</p>
  
  <p>I have following code which converts the QString to QByteArray</p>
  
  <pre><code>//'socketMessage' is the QString, listener is the QTcpSocket
  QTextCodec *codec = QTextCodec::codecForName("UTF-16");
  QByteArray data = codec-&gt;fromUnicode(socketMessage);
  listener-&gt;write(data);
  </code></pre>
  
  <p>I have even tried the QTextStream,QDataStream etc for encoding. But everytime I end up with the same result. Am I doing something wrong here?</p>