Unsolved How to make QFile read the whole line
-
@VRonin but thsi doest read the full data
-
No sir i checked the read by removing the NUL from the data in the file and i was able to see that it read the whole data and qDebug() was displaying the full data
This is the whole data when i removed the NUL : " WQA.,?E>t1?dWQA.,DE_??n1?d7be1526df618c0c4d1bab3959adb65ada9f20bd969493e532a7861d29bc6e698{TB.)?V1??n1?dS[H21?z7_??n1?d340819615bcd7cb87459cac37070456eb0af53716c1f0064c4771857728d3777 "
-
But when the data conatins NUL the data will be " WQA.,?E>t1?dWQA.,DE_??n1?d7be1526df618c0c4d1bab3959adb65ada9f20bd969493e532a7861d29bc6e698 "
-
@ManiRon said in How to make QFile read the whole line:
but thsi doest read the full data
What is the output of
qDebug() << actualRead << size_of_file;
?
-
@jsulm said in How to make QFile read the whole line:
size_of_file
Size = 194 .
I thought it was qdebug problem so i wrote the data read from the file to another file then also it remains the same as the data shown in the debug
-
What is the value of
actualRead
? -
Size = 194
-
That means the read doesn't actually stop with the null
-
This post is deleted! -
Yes you are right sir, So what can we do ?
-
@ManiRon
"What can we do" about what? You've spent the whole time claiming the read stops at the NUL, now you confirm it does not, so what's the problem? -
I am storing the data in QBytearray will that be a problem?
-
the size it specifies is correct but the data displayed is till the NUL
-
@ManiRon said in How to make QFile read the whole line:
the size it specifies is correct but the data displayed is till the NUL
But I said that was just how
qDebug()
displays data. Read up about howqDebug()
displays strings/bytes, which may contain NUL. -
I have doubt in storing the data i store the data read in QBytearray
-
@ManiRon
So read up howqDebug()
displays aQByteArray
(as well as aQString
)!!
Something even as old as https://www.qtcentre.org/threads/54236-qDebug-donsn-t-display-0x00?p=243053#post243053 will presumably do you..... -
Yes sir i can understand that it will take NUL as a terminate . Is there any way that i can store the full data along with the NUL
-
@ManiRon said in How to make QFile read the whole line:
Is there any way that i can store the full data along with the NUL
It is stored, just qDebug() stops it's output when it sees NUL. Take a look at the link @JonB provided above.
-
@Christian-Ehrlicher sir i checked the data are read from the file fully but the problem is the way i store . I tried to store it in a QByteArray variable, a char array Variable, a QString Variable but all are terminating when the data has a NUL Inbetween, Now its not the problem of qDebug .
-
You really should try to understand what we wrote. When you QFile::read() returns exactly the size of the file then all bytes are read and stored in the QByteArray. Just because qDebug() stops at NUL doesn't mean there is no data after that...