It seems that a call to the function ON_wString::Array() retruns a NULL pointer if the string is empty.
I expected it returns a valid pointer to an empty char (like std::wstring does).
Is it a bug, a desired behavior or I’m doing something wrong?
Extra question:
During the copy of an ON_wString to a std::wstring (e.g. std::wstring stdString = ON_wString(“foo”)) which is the function that handles the conversion?
I though there was a cast operator from ON_wString to wchar_t* or something similar but I did not find such a function.
Couldn’t it return a valid pointer to an NULL (L’\0’) character when the function ON_wString::Array() is called?
As std::wstring does so with its function std::wstring::c_str() for example.
Maybe I miss something obvious for you…
ON_wString str = L"";
const wchar_t* charPointer = str.Array(); // This return a NULL pointer
std::wstring str1 = L"";
const wchar_t* charPointer1 = str1.c_str(); // This return a valid pointer to a NULL char
Yes, I see that. We can fix ON_wString::Array in the current version of Rhino. But we’re not going to fix Rhino 5. Thus, your best bet is probably to create a utility function that does the conversion in your preferred manner.