gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit 38ec5288ac23b2ba3a562ca7eb53e2de0c6477d0
parent 689dee33da1a508cdcd31fb20373d7267f337a76
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Sat, 26 Feb 2022 23:16:56 +0100

fix failing to load midi files with non-ascii character due to Juce converting every filename to UTF-8

Diffstat:
Msource/synthLib/midiToSysex.cpp | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/source/synthLib/midiToSysex.cpp b/source/synthLib/midiToSysex.cpp @@ -6,9 +6,28 @@ namespace synthLib { +#ifdef _MSC_VER +#include <Windows.h> + std::wstring ToUtf16(const std::string& str) + { + std::wstring ret; + int len = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), static_cast<int>(str.size()), NULL, 0); + if (len > 0) + { + ret.resize(len); + MultiByteToWideChar(CP_UTF8, 0, str.c_str(), static_cast<int>(str.size()), &ret[0], len); + } + return ret; + } +#endif + bool MidiToSysex::readFile(std::vector<uint8_t>& _sysexMessages, const char* _filename) { +#ifdef _MSC_VER + FILE* hFile = _wfopen(ToUtf16(_filename).c_str(), L"rb"); +#else FILE* hFile = fopen(_filename, "rb"); +#endif if (hFile == nullptr) {