[Solved] Text's Encoding... Which is the best way to resolve this "problem".
-
Well, I have an application show creates your own database, using a text file with "creates" and "inserts", in this may I make an application who can run on memory stick/pendrive.
But In linux all data that I generate on database is showed in right encoding, but on windows don't show the right text's, I know that is enconding problem.
How can I fix it in simple way? Can be something in encoding database, is something when I show the text on screen....
I have some other messages with same error too...My application uses this chars: "çãáàü...."!
How can I fix it?! If code need ask me and I post how I create the database, or read from database or anything like that.Thanks
-
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.