Results 1 to 3 of 3

Thread: Get Korean string from MYSQL(KUBUNTU)

  1. #1
    Join Date
    Jul 2008
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Get Korean string from MYSQL(KUBUNTU)

    Hello. I'm newbie on QT.

    I'm sorry for my english.

    I want to display MessageBox that include Korean string(from MYSQL).

    Numeric with Alphabet is well done. Only Korean string is broken display.

    The Code is like it.
    -------------------------------------
    Qt Code:
    1. QSqlQuery *query= new QSqlQuery("select Name from User where id='"+id+"' and password='"+password+"'"); //set query
    2. //Name is Korean String char(12)
    3.  
    4. query->exec();
    5. query->next();
    6.  
    7. QString temp1;
    8. temp1=query->value(0).toString(); [B][I]// this step need not convert encoding????[/I][/B]
    9.  
    10. QByteArray temp=temp1.toLocale8Bit();
    11. char *string=temp.data();
    12. QMessageBox::information(this, "Information", QString::fromUtf8(string), QMessageBox::Ok);
    To copy to clipboard, switch view to plain text mode 
    Last edited by morgana; 5th July 2008 at 00:19.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Get Korean string from MYSQL(KUBUNTU)

    What's the encoding of the string in database? What does
    Qt Code:
    1. QMessageBox::information(this, "Information", temp1, QMessageBox::Ok);
    To copy to clipboard, switch view to plain text mode 
    show?
    J-P Nurmi

  3. #3
    Join Date
    Jul 2008
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Get Korean string from MYSQL(KUBUNTU)

    Quote Originally Posted by jpn View Post
    What's the encoding of the string in database? What does
    Qt Code:
    1. QMessageBox::information(this, "Information", temp1, QMessageBox::Ok);
    To copy to clipboard, switch view to plain text mode 
    show?
    I solved.
    The cause is MYSQL encoding.
    I got information MYSQL encoding set by latin.(show variables like 'c%')
    Korean is not latin.
    1. So i changed encoding latin to UTF8(edit my.cnf)
    2. And table character set change UTF8.
    Alternative: CREATE DATABASE [db_name] DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

    thanks to interesting.

    Have a nice dream.

Similar Threads

  1. Problems with korean symbols in file path
    By Raistlin in forum Qt Programming
    Replies: 5
    Last Post: 6th April 2008, 14:59
  2. Reading from sockets in a multithreaded program
    By KoosKoets in forum Qt Programming
    Replies: 9
    Last Post: 4th April 2007, 21:43
  3. saving a c string of variable length in a shared memory?
    By nass in forum General Programming
    Replies: 4
    Last Post: 3rd January 2007, 15:40

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.