No the files are not always "string - string" and i'm not sure if they are pure ascii...i need some code that works on every file :S
No the files are not always "string - string" and i'm not sure if they are pure ascii...i need some code that works on every file :S
You need to know what encoding to use as there are countless ways to interpret bytes. You could add a setting to your program configuration, to make user choose the encoding (by default its taken from locale).Originally Posted by Buhmann
Oh, I didn't know that... In fact I only want the bytes I guess. I don't want to do anything with the file, I just want it itself :POriginally Posted by jacek
In VB6 I only had toand then read it withQt Code:
Open "Path" For Binary As #FTo copy to clipboard, switch view to plain text modeand everything worked fine...which function matches this in qt? :SQt Code:
StrBuffer = String(10240, " ") Get #F, , StrBufferTo copy to clipboard, switch view to plain text mode
Try:If you are lucky enough, it might workQt Code:
To copy to clipboard, switch view to plain text mode![]()
Originally Posted by wysota
Thanks, but even if it works, I need 1024 bytes and not a line out of the file :S
I'm getting desperate. Why is my problem so hard to solve? I thought it must be simple and I'm just blind :S
So don't read a line but 1024 bytes. My point was to use QString::fromLocal8Bit(). QString has to know, how to convert raw bytes to unicode, you have to tell it how to do it.
Qt Code:
MyFile.setFileName("c:\test.txt");To copy to clipboard, switch view to plain text mode
how about:
Qt Code:
MyFile.setFileName("c:\\test.txt"); MyFile.setFileName("c:/test.txt");To copy to clipboard, switch view to plain text mode
You know, you are backslashing "t"....
But that would mean there should be no input at all...but i got input, the problem is, that it's partly wrong :/
And the problem with fromLocal8Bit is, that it needs const char* and it seems that I'm too silly to get it run :S
If you try to compile your program with other compiler, you won't be able to open that file. It's a non-standard extension introduced by M$. In real C++ "\t" is interpreted as tab character, so under windows you should use "\\" for paths. AFAIR, you can also use "/" as Qt will change it to "\\".Originally Posted by Buhmann
You can read that data to QByteArray and then use QByteArray::data() or use QTextStream::read() (and forget about QString::fromLocal8bit()).Originally Posted by Buhmann
Bookmarks