Using CharPointer_UTF8 in juce_VSTPluginFormat.cpp


#1

Hi Jules,

One or two of my third-party plugins have plugin names, and parameter names that trigger assertions in the String class. Probably because they use an odd character format (from juce’s perspective). I’ve been having to add modifications such as this to the juce_VSTPluginFormat.cpp file to make them go away in VC2010 debug mode. I’ve added the CharPointer_UTF8 in other places in the file also. It appears I tagged the places I made changes so if you want a more complete list, or if you want some plugins that trigger the assertions just let me know.

In the example below note usage of CharPointer_UTF8

const String VSTPluginInstance::getCurrentProgramName()
{
    if (effect != nullptr)
    {
        char nm [256] = { 0 };
        dispatch (effGetProgramName, 0, 0, nm, 0);

        const int index = getCurrentProgram();
        if (programNames[index].isEmpty())
        {
            while (programNames.size() < index)
                programNames.add (String::empty);

            programNames.set (index, String (CharPointer_UTF8 (nm)).trim()); // kurt6string
        }

        return String (CharPointer_UTF8 (nm)).trim(); // kurt6string
    }

    return String::empty;
}

#2

I think I avoided doing that because a plugin might not be using utf-8… But… I guess assuming it’s utf-8 is probably slightly better than assuming it’s ascii, so maybe this isn’t a bad idea!


#3

I haven’t noticed the changes bothering anything else so far…crossing fingers.