The good news is it’s just an assertion. In a release build you just get a string in the metadata with invalid characters. Whatever happens subsequently depends on the calling code.
Unfortunately I think there is no easy fix. You can turn the
jassert (CharPointer_UTF8::isValidString (buffer, bufferSizeBytes));
into an if to catch it, but there is no way to know the actual encoding if it’s not UTF8.
Something like this could work:
if (CharPointer_UTF8::isValidString (buffer, bufferSizeBytes));
return String (CharPointer_UTF8 (buffer), CharPointer_UTF8 (buffer + bufferSizeBytes));
else
return String (buffer, bufferSizeBytes); // constructs from raw ascii
But I am not sure if it’s the right thing to do…