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 in Qt

Chinese in Qt

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.7k 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.
  • B Offline
    B Offline
    bask185
    wrote on last edited by bask185
    #1

    Hi
    alt text
    This screenshot is a .csv file (which is extracted from a .mdb file) opened in LibreOffice Calc. It contains translations, I now can translate most languages with the exception of Chinese and Thai (and arabic but this matters not).

    You can see that Slovakian is properly translated and that Chinese/Thai exists out of numbers. I need to treat these numbers as ascii values. You see alot 32 (spaces) and there are numbers which have a value of Chinese and Thai symbols/lettres.

    The value of which I am talking is this:

    "Excel uses ANSI code system for Windows computers: Excel uses the standard ANSI character set, for Windows systems. The Windows operating environment uses the ANSI character set, whereas Macintosh uses the Macintosh character set - hence the characters returned for the same numerical values by the Excel Char Function may vary across operating environments. Similar to the excel vba function of Chr, you have the vba ChrW function which returns a Unicode character for the specified character code, and again you have the excel vba Asc and AscW functions, wherein AscW returns the Unicode character code for the specified character. "

    source: link text

    I am dealing with the vba Chrw function... on Linux.

    After I have succesfully captured the number string and turned it into an integer,

    How I do get the corresponding Chinese/Thai symbol in Qt? Must I download something? I suppose Qt already has standard libraries and functions for this? I just don't know which ones and I am not having much succes with google today.

    P.S.
    I am cross-compiling for the raspberry pi 3, so IDK if will have a problem with missing files or something...

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bask185
      wrote on last edited by bask185
      #3

      Tnx, that extra info was fun to read. I have come a long way with the translating. I already have chinese characters on my screen, but I am having a small problem with converting a String to an integer.

      void MainWindow::PrintUTF(QString S)
      {
          bool ok;
      
          int UTF = S.toInt(&ok, 16);
      
          if (UTF < 0) UTF += 65535;
          qDebug() << "numeric value ="<< UTF << S;
      
          monitors[index1]->model()->setData(monitors[index1]->model()->index(row[index1],column[index1]),QBrush(color[colorIndex[1]]),Qt::ForegroundRole); // sets the color of the lettre
          monitors[index1]->model()->setData(monitors[index1]->model()->index(row[index1],column[index1]++),QChar(UTF));  // stuffs the character in the text array with the active color.
      }
      

      The problem is that the string happens to contain decimal values and not hex values.
      So when I have String "32" the output becomes 50.

      I don't know what the simplest way is to fix this?

      EDIT: by changing the 16 in 10 ofcourse -_-"

      1 Reply Last reply
      2
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #2

        Hi
        so what you have in the Chinese column is all the characters each saved as the unicode value?
        You can try
        QString s = QChar(0x4FF0);
        0x4FF0 being the unicode. 𢐂

        For info if needed
        https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/

        1 Reply Last reply
        4
        • B Offline
          B Offline
          bask185
          wrote on last edited by bask185
          #3

          Tnx, that extra info was fun to read. I have come a long way with the translating. I already have chinese characters on my screen, but I am having a small problem with converting a String to an integer.

          void MainWindow::PrintUTF(QString S)
          {
              bool ok;
          
              int UTF = S.toInt(&ok, 16);
          
              if (UTF < 0) UTF += 65535;
              qDebug() << "numeric value ="<< UTF << S;
          
              monitors[index1]->model()->setData(monitors[index1]->model()->index(row[index1],column[index1]),QBrush(color[colorIndex[1]]),Qt::ForegroundRole); // sets the color of the lettre
              monitors[index1]->model()->setData(monitors[index1]->model()->index(row[index1],column[index1]++),QChar(UTF));  // stuffs the character in the text array with the active color.
          }
          

          The problem is that the string happens to contain decimal values and not hex values.
          So when I have String "32" the output becomes 50.

          I don't know what the simplest way is to fix this?

          EDIT: by changing the 16 in 10 ofcourse -_-"

          1 Reply Last reply
          2

          • Login

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