Hi,

Flash 10, action script 4 sends strings this way:
int16 describing size
then char * data.

To my knowledge, this type of string is not serialized in QT.

so i made this class:
Qt Code:
  1. class FlashDataStream : public QDataStream
  2. {
  3. public:
  4. FlashDataStream () : QDataStream() {}
  5. FlashDataStream ( QIODevice * d ) : QDataStream(d) {}
  6. FlashDataStream ( QByteArray * a, QIODevice::OpenMode mode ) : QDataStream(a, mode) {}
  7. FlashDataStream ( const QByteArray & a ) : QDataStream (a ) {}
  8.  
  9. QString ReadUTF8(qint16 maxsize = 4096)
  10. {
  11. Q_ASSERT(maxsize <= 4096);
  12.  
  13. static char buffer[4096];
  14. qint16 stringlength;
  15. (*this) >> stringlength;
  16.  
  17. if (stringlength < maxsize)
  18. {
  19. readRawData(&buffer[0] , stringlength);
  20. }
  21. return QString::fromAscii(buffer, stringlength);
  22. }
  23.  
  24. void WriteUTF8(QString data)
  25. {
  26. (*this) << data.size();
  27. writeRawData((char*)data.data(), data.size());
  28. }
To copy to clipboard, switch view to plain text mode 

Now, my question is; There has got to be a better way of reading the string than having to copy those bytes twice. Is there a way to achieve what i am doing in one operation?