cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
Docmatic
Participant

Convert GS::UniString to char*

Hi guys,  I am tryng to use curl_lib in my Archicad Addon.   How can I convert a GS::Unistring to  char*

 

Thank you

2 Replies 2
Miha Nahtigal
Expert
const char* cString = gsUniString.ToCStr().Get();
BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.
Miklos Vegh
Graphisoft
Graphisoft

You should not instantiate a pointer with the result of ustr.ToCStr().Get().

The ToCStr() returns a CStr object which is created on the stack. When the next statement is executed the CStr object will be destroyed resulting an invalid pointer.

Use .ToCStr().Get() in function parameters only.

 

If you want to have a pointer use ustr.CopyUTF8 ()  instead, which returns a pointer to a newly allocated copy. This needs to be freed with delete[].

 

 

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!