Results 1 to 4 of 4

Thread: QFile using utf-8

  1. #1
    Join Date
    Apr 2009
    Posts
    12
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Smile QFile using utf-8

    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

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFile using utf-8

    take a look at QTextStream::setCodec.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. The following user says thank you to spirit for this useful post:

    Mr.QT (30th April 2009)

  4. #3
    Join Date
    Apr 2009
    Posts
    12
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Smile Re: QFile using utf-8

    Hi Spirit.

    Thanks a lot ..

    Do you think this will do for file saving as will.
    Qt Code:
    1. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    To copy to clipboard, switch view to plain text mode 

    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.
    Qt Code:
    1. out << property->getInsertSql().toUtf8() <<'\n';
    2. out << property->getInsertEF().toUtf8()<<'\n';
    To copy to clipboard, switch view to plain text mode 

    After your replay I think this is the best.
    Qt Code:
    1. QTextStream out(&sqlFile);
    2. out.setCodec(QTextCodec::codecForName("UTF-8"));
    To copy to clipboard, switch view to plain text mode 

    I hop it will work.

    Thanks

    Best Regards

  5. #4
    Join Date
    Apr 2009
    Posts
    12
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Smile Re: QFile using utf-8

    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

Similar Threads

  1. QFile locks debug environment in QThread
    By nickolais in forum Qt Programming
    Replies: 1
    Last Post: 12th February 2009, 07:20
  2. QFile can't read a file
    By Raccoon29 in forum Qt Programming
    Replies: 3
    Last Post: 11th February 2009, 20:24
  3. QFile -> std::fstream
    By bhs-ittech in forum Qt Programming
    Replies: 1
    Last Post: 9th June 2008, 10:02
  4. Passing QFile objecrt as parameter
    By db in forum Newbie
    Replies: 2
    Last Post: 28th August 2007, 16:09
  5. QFile and Creating Files
    By Jingoism in forum Newbie
    Replies: 2
    Last Post: 28th July 2007, 17:11

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.