PDA

View Full Version : QFile using utf-8



Mr.QT
30th April 2009, 10:44
Hi

I'm having problem getting some data to .sql file.
I have got some data which has some format into SQL for MySql ..


It's working and every thing but, when you wan to show the data as french language.
it' does not...

In the .sql file you can see all the alphabet correctly.
but after you run the queries, and try to show the data. you see some of the results are not showing.

Is it because of the utf-8 .. I have changed the database to utf-8.
but how to change the file QFile to utf-8.

Regards

spirit
30th April 2009, 11:03
take a look at QTextStream::setCodec.

Mr.QT
30th April 2009, 11:55
Hi Spirit.

Thanks a lot ..

Do you think this will do for file saving as will.


QTextCodec::setCodecForCStrings(QTextCodec::codecF orName("UTF-8"));


I have add this into the code as will.
I have Class which you set some data in it then you call getInsertSql() and
it will make the SQL statement .. i do not know if .toUtf8() will help.


out << property->getInsertSql().toUtf8() <<'\n';
out << property->getInsertEF().toUtf8()<<'\n';


After your replay I think this is the best.


QTextStream out(&sqlFile);
out.setCodec(QTextCodec::codecForName("UTF-8"));


I hop it will work.

Thanks

Best Regards

Mr.QT
30th April 2009, 12:17
Hi spirit,

Thank you ..
It did work. and even for a big scale


Import has been successfully finished, 45678 queries executed.
and all with the correct view we need for this problem.

Best Regards