2022-12-10 06:48 AM
Hi guys, I am tryng to use curl_lib in my Archicad Addon. How can I convert a GS::Unistring to char*
Thank you
2022-12-10 08:38 AM
const char* cString = gsUniString.ToCStr().Get();
2023-02-13 08:13 PM
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[].