Writing raw bytes as text?
I have a file that I wrote bytes to (MyFile below)... these bytes were actually just xml text originally, but were written as bytes or a bytearray. My question is how would I take those raw bytes and write them as the xml text they represent to a different file?
Code:
QFile fileReadIn
("MyFile");
if (fileReadIn.
open( QFile::ReadOnly )) {
QFile testFile
( "Result.xml" );
testFile.write(fileReadIn.readAll());
}
Re: Writing raw bytes as text?
That depends on the contents of your input file.
Could you please clarify what you mean by "written as bytes or a bytearray"?
Basically: You need to read them "inverse to the way you wrote them", convert that bytearray into a QString and then write that (in the desired encoding) to your output file.