[Qt-interest] How to get unicode data from socket?
Alex
shao.tu at gmail.com
Fri Jan 15 02:20:47 CET 2010
Hi, all,
Thanks for all people answered the question.
Due to the data are unicode string.
Plus, the data is sent by a third party non-QT based application.
So I don't think QDataStream can fit my requirement.
Now, I know I should use fromUtf16() to convert it.
But, its prototype is *fromUtf16(const ushort* unicode, int size=-1)*
and I can't find a way to convert a ByteArray to a pointer of ushort.
Moveover, anyone knows an alternative of memcpy()?
Thanks.
Alex
2010/1/14 Alex <shao.tu at gmail.com>
> Hi,
>
>
> I have a program written in QT and it receives data via socket connection.
> The data format is:
> +--------------------+-----------------------+
> *| sizeOfData(4bytes) | Data (Unicode string) |*
> +--------------------+-----------------------+
> My questions are:
>
> 1. After I read the first 4 bytes data, I use memcpy() to get/convert
> the following data size. Does QT provide a convenient way to achieve this
> instead of memcpy()?
> 2. I use QTcpSocket.read(sizeOfData), which returns the QByteArray, to
> read the real data but I can't find a way to convert it to QString. How
> should I do?
>
>
> Thanks.
> Alex
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100115/e69a65d9/attachment.html
More information about the Qt-interest-old
mailing list