Bank loading and unicode

Is there a way to pass 2-byte unicode file path to the FMOD::Studio::System::loadBankFile like there is with FMOD_UNICODE flag for FMOD::System::createSound?
I know I can use FMOD::Studio::System::loadBankCustom, but I’d like to avoid redundant implementing of all the callbacks, since they would be pretty standard.

Currently the Studio API does not provide a way to specify a UTF-16 path to FMOD::Studio::System::loadBankFile().

We are planning to add full Unicode support to Studio in the near future. Actually we have decided on the UTF-8 standard, rather than UTF-16, as this encoding is more compatible with our existing API (which generally uses char* for string arguments), and is somewhat more portable across all platforms. In any case, it is relatively easy to convert between UTF-16 and UTF-8 encodings.

For now, your best option is to use FMOD::Studio::System::loadBankCustom(), as you have suggested.

As of version 1.05.00, all FMOD functions dealing with file names and paths now accept UTF-8 encoded strings. All arguments that take or return UTF-16 encoded strings have actually been removed, as have related flags like FMOD_UNICODE.

Now you can just use UTF-8 strings everywhere. If you have a UTF-16 (wide string) file path, just convert it to UTF-8 encoding and pass that to FMOD::Studio::System::loadBankFile().

On Windows, you could do something like…

FMOD::Studio::Bank* LoadBankWide(FMOD::Studio::System* system, const wchar_t* filenameW)
    char filename[MAX_PATH];
    WideCharToMultiByte(CP_UTF8, 0, filenameW, -1, filename, sizeof(filename), NULL, NULL);

    FMOD::Studio::Bank* bank = NULL;
    system->loadBankFile(filename, FMOD_STUDIO_LOAD_BANK_NORMAL, &bank);

    return bank;
1 Like