Chinese in Qt
-
Hi
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... -
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 -_-"
-
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/ -
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 -_-"