BIM Coordinator Program (INT) April 22, 2024
Find the next step in your career as a Graphisoft Certified BIM Coordinator!
Archicad C++ API
About Archicad add-on development using the C++ API.

LibXL - How to convert GS::UniString to wchar_t *?

cfranklin
Newcomer
Hi,

I'm looking at the Database_Control example for Archicad 23 and I see that the example shows using a define to convert:
 UNISTR_TO_LIBXLSTR(str) (str.ToUstr ()) 
, however I cannot get the example or my own project to build when following this code. I get an error that
no suitable conversion function from "GS::UniString::UStr" to "const wchar_t *" existsC/C++(413)
, is this example not up to date or is there some other way to convert the GS::UniString to the correct type for the excel library?

Thanks
3 REPLIES 3
Ralph Wessel
Mentor
Which compiler, version and toolset are you using?
Ralph Wessel BArch
Anonymous
Not applicable
I was able to convert a UniString to a wstring in C++ using:

(str is a GS::UniString)

GS::UniChar::Layout* valptr = str.CopyUStr(0, str.GetLength());
wstring endstr;
for (int j = 0; j < str.GetLength(); j++) {
		wchar_t temp = wchar_t(*(valptr + j));
		endstr += temp;
}
I basically had to loop through it using pointers and convert each character. There's probably a better way to do this though.
Ralph Wessel
Mentor
If it works in one of the example projects, it should work for everyone. If it doesn't, it suggests a compiler version or toolkit outside the range specified by GS is being used. If you want a real answer, it would be useful to know which compiler, version and toolset are you using.
Ralph Wessel BArch
Learn and get certified!

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!