[Solved] Text's Encoding... Which is the best way to resolve this "problem".
-
I have my file in utf-8 too. I compile my project under Linux and Windows. I use Qt Creator and mingw on Windows and my app work good if I use
@
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
@
on begin of my program. Your app should work good without converting to ISO-8859-1. Where you have a problem? Paste some code for example issue. -
I don't find a way to read the file and set the encoding of file:
@
QString Database::readCreateTable()
{
QFile file(":/database/CreateTable.sql");
if(!file.open(QIODevice::ReadOnly))
{
qDebug() << "error opening file: " << file.error();
return "";
}
QTextStream instream(&file);
QString createTable =instream.readAll();
file.close();
return createTable;
}
@This will work? "http://qt-project.org/doc/qt-4.8/qfile.html#setEncodingFunction":http://qt-project.org/doc/qt-4.8/qfile.html#setEncodingFunction
-
Maybe try "setCodec() from QTextStream":http://qt-project.org/doc/qt-4.8/qtextstream.html#setCodec-2 ?
"Example of use":http://www.qtcentre.org/threads/2808-Qfile-and-QTextStream but I don't know if this is good.