Results 1 to 2 of 2

Thread: SQLite reading Chinese strings issue

  1. #1
    Join Date
    Jul 2009
    Location
    Jordan, and UAE
    Posts
    55
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default SQLite reading Chinese strings issue

    Good day

    I have a sqlite table that has a simplified Chinese column, and I want to preview that table in QSqlTableModelI was able to print Chinese characters to the label using the following code
    Qt Code:
    1. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GB2312"));
    2. QString a= "T氓颅鈥斆ヂ嘎";
    3. ui->label->setText(a);
    To copy to clipboard, switch view to plain text mode 

    and it shows OK, so I think the issue is when reading from the db. I've tried SQLite administrator tool and it shows the table with the Chinese entries OK

    What do you think a solution to this issue is?

    Thanks!
    Last edited by yazwas; 5th April 2011 at 12:57.

  2. #2
    Join Date
    Jul 2009
    Location
    Jordan, and UAE
    Posts
    55
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SQLite reading Chinese strings issue

    I fixed this by using the following

    Qt Code:
    1. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GB18030")); //gb18030 was the encoding of the data.
    2.  
    3. //then using a query to retrieve the data, and display like below
    4. QString str = query.value(0).toString().toUtf8(); //this would show a correct encoding of the data!
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Mysql and Arabic encoding issue
    By yazwas in forum Qt Programming
    Replies: 5
    Last Post: 23rd March 2011, 16:43
  2. QDevelop SQLite Driver Issue
    By Phan Sin Tian in forum Qt-based Software
    Replies: 4
    Last Post: 1st August 2010, 12:47
  3. MySQL UTF-8 encoding issue
    By yazwas in forum Qt Programming
    Replies: 5
    Last Post: 15th February 2010, 09:29
  4. SQLite connection and encoding
    By mhbeyle in forum Qt Programming
    Replies: 2
    Last Post: 3rd December 2009, 16:25
  5. SQLite encoding problem
    By cevou in forum Qt Programming
    Replies: 3
    Last Post: 27th September 2009, 22:37

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.