The BOM will definitely be needed for a UTF-16 stream. Easiest way is to change one line in your code:
std::wstring test = L"\uFEFFRandom test.\nTest test.\nThis is UTF-16.";
That's the good news. The bad news is that it turns out DVP_LoadText
is semi-broken at the moment.
We've found where it's broken and have a fix coming.
For the time being, there's a kludge you can add to the plugin which will make it work with the current Opus version. It's probably not something you want in a finished release version but it lets you get on with things while you wait for us to fix our side.
(Basically, the text viewer needs to verify it can handle the data, but instead of looking at the stream your plugin provides, it is looking at the original file's data that was already cached in reaction to another plugin. Since patch files are not plain text, the text viewer is rejecting the file. The kludge is to overwrite the cached buffer with text data -- "aaaaa..." will do -- to trick the text viewer into accepting it. Strictly, this isn't allowed as that buffer is read only to plugins and could conceivably be needed for something else in the future, but we can get away with it for now, as a temporary workaround.)
Here's a version that works with Opus 12.6, with comments in the code. Only the main .cpp and .h were changed so if you diff them you can see the changes:
ZPatchViewer_a2_leo.zip (18.4 KB)