Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Chinese with Qt

Chinese with Qt

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 4.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    ThaRez
    wrote on last edited by
    #1

    hello
    I'm working on a Qt based project which should do the following:

    • store information in a sqllite database

    • transfer it using xmlrpc

    • display it in a gui

    This is all working with "normal" characters, but I'm reall confused how to proceed with chinese...
    I do not know any chinese nor anything about the structure of the language, and my knowledge
    regarding different kinds of encodings is limited.

    Any suggestions how to proceed and what should be acknowledged? I don't even know where to start...
    Thanks
    Richard

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MuldeR
      wrote on last edited by
      #2

      Qt provides full Unicode support. So as long as you use QString (it uses Unicode encoded as UTF-16 internally) for your strings, Chinese or whatever characters are no problem at all! Also all GUI widgets of Qt support Unicode, so just set the text from a QString, e.g. QLabel::setText(myStr) where myStr is a QString, and you should be fine.

      Only remaining problem is to get the text from your DB into a QString properly. If the data in your DB is encoded in UTF-8, for example, you can construct a proper QString with QString::fromUtf8(...). If the text in the DB is encoded in some "regional" 8-Bit Codepage, you can convert it to a QString and thus UTF-16/Unicode by using QTextCodec::toUnicode(). In the latter case you will have to know the proper Codepage beforehand, of course.

      (For Chinese text the "Big 5" Codepage is a good candidate. Unicode is always preferable though!)

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dbzhang800
        wrote on last edited by
        #3

        Hi ThaRez,

        You should tell us which encoding your used in

        • your sqlite database
        • when transfer in xmprpc
        • your remote gui

        Three encodings widely used in Chinese:

        • UTF-8
        • GB18030 (also known as GBK/GB2312), China Mainland and Singapore
        • Big5, China Taiwan and Hong Kong
        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved