Frage

I'm trying to transfer a file using a QTcpSocket. The connection runs fine, but my problem is when I try to record the received bytes on a file. When I open the file there are some strange characters at the beginning of the file. What are these characters?

War es hilfreich?

Lösung

My problem was that I was saving the whole object in my file. When we use the operator >> in a stream, the Qt serializes the whole object and sends it. If you want write only the bytes of your file, or whatever you want, you need to use writeRawData or the write methods passing the char * for the bytes.

:)

Andere Tipps

They probably are describing the encoding of the file's text. Such as UTF-8 v. ISO### standards. If you take the block of text and set it to the proper encoding, those characters will most likely disappear.

Here is starting place to learn about it:

http://en.wikipedia.org/wiki/Unicode_and_HTML

http://qt-project.org/doc/qt-4.8/qstring.html#toUtf8

Hope that helps.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top