Let’s suppose that I have created a juce::String from a C-style const char*,
const char* cstring = “Some text”;
How do I convert it back to a const char*? The standard library has std::string::c_str(), but is there a juce::String function doing the same? I have found juce::String::toWideCharPointer(), which gives me a const wchar_t*, but that’s not what I want. I need to pass the string to another function which expects a C-style const char* (not wide character). I figured that I could get a UTF-8 pointer and just cast it to const char*,
const char* new_cstring = static_cast<const char*> (string.toUTF8());
since ASCII is forward-compatible with UTF-8, but that seems like a very ugly solution and probably wrong. Is there a better way?
Any help appreciated…