Hi,
i read files like this,
string entire;
char buf[1024];
while (device->readLine(buf, sizeof(buf)) && !device->atEnd()) { //QIODevice = device
entire += buf;
//...
}
size_t length = entire.length();
for (size_t i = 0; i < length; ++i) {
char c = entire[i];
//...
s.append(c);
}
string entire;
char buf[1024];
while (device->readLine(buf, sizeof(buf)) && !device->atEnd()) { //QIODevice = device
entire += buf;
//...
}
size_t length = entire.length();
for (size_t i = 0; i < length; ++i) {
char c = entire[i];
//...
s.append(c);
}
To copy to clipboard, switch view to plain text mode
but my QSting ("s") looks dirty. The problem is the file can be coded in utf8, iso 8859-15 and a lot more.
How can i read the file with the right codec, if the user choose the codec before?
I have try QTextCodec::setCodecForCStrings( QTextCodec::codecForName( codec ) ) but i hink thats not right. Can you help me pleas?
Bookmarks