cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Archicad C++ API
About Archicad add-on development using the C++ API.

SingleSelList Not Displaying Japanese Text in Palette

NMK195
Participant

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.

 

NMK195_0-1752295175266.png

	// 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);

 

3 REPLIES 3
Hiromichi Shinkawa
Graphisoft
Graphisoft

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.

Miklos Vegh
Graphisoft
Graphisoft

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.

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?

 

NMK195_0-1752720309192.png

 

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!