2025-07-12 06:42 AM
Hello everyone,
I am creating a palette that contains a SingleSelList to display object variable information—similar to the “Object Selection Settings” dialog—but when the uDescname value contains Japanese characters, it fails to display correctly. I’ve tried various approaches suggested on forums for handling Japanese and Chinese characters (such as using std::wstring), but without success. Does anyone have a solution to this issue?
Thank you in advance.
// Draw Text
TE::Font fontPlain;
DG::GetFont(DG::Font::Large, DG::Font::Plain, &fontPlain);
const double padding = fontPlain.GetCapISize() * 1.5;
double top = padding;
GS::UniString uStr((*data.paramsLib)[item - 1].name);
context.DrawPlainText(uStr, fontPlain, padding, top, 0);
std::wstring wStr = (*data.paramsLib)[item - 1].uDescname;
GS::UniString uStr1(wStr.c_str());
context.DrawPlainText(uStr1, fontPlain, padding, top + 20, 0);
2025-07-16 11:27 AM
Hi, I'd suggest you try the conversion option CC_Japanese like the following code in case of Japanese charactor:
char* pChar = "文字"
GS::UniString str (pChar, CC_Japanese);
HTH.
2025-07-16 01:16 PM
Hi, if the ANSI characters look fine but Japanese don't, it's more likely a character encoding problem. I assume the problem is in the GS::UniString constructor.
In general, raw strings in ArchiCAD are UTF-8 encoded. If in this case the name is a char*, then it can be UTF-8.
In this case the GS::UniString should be constructed with the UTF-8 character encoding specification like this:
GS::UniString uStr ((*data.paramsLib)[item - 1].name, CC_UTF8);
Note: Implementing an owner-drawn listbox is more complicated than implementing a simple listbox. And if you do not need an owner-drawn listbox, you can simply use the SetTabItemText(...) member function to set content on the listbox cells and you do not have to deal with padding, text drawing and so on.
2025-07-17
04:45 AM
- last edited on
2025-07-18
05:03 PM
by
Laszlo Nagy
Thank you for your answer! Actually, I had already tried using that syntax, but the displayed content still had font issues. Later, I switched to displaying it similar to the AttributeListDialog example, and it worked properly.
However, now I have a new problem: in the API, how can I retrieve the list of values defined in a GDL object?