Developer forum
Showing results for 
Search instead for 
Did you mean: 

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


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?


Ralph Wessel
Which compiler, version and toolset are you using?
Ralph Wessel BArch

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

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!