Author Topic: Bass and Unicode - How to  (Read 432 times)


  • Posts: 6
Bass and Unicode - How to
« on: 5 Apr '19 - 22:08 »
I use my C++ on cross platform. ON macOS and Linux the bass lib is working well with my code. On Windows I got some problems with Unicode.

I use:
Code: [Select]
bool returnVar = _BASS_SetConfig(BASS_CONFIG_DEV_DEFAULT,1);
            if (!_BASS_Init(-1,44100,0,NULL,NULL)) {
                return false;
char file[MAX_PATH] = "";
strncpy(file, strFileName.GetAsUtf8(), sizeof(file));

g_BassHandle = _BASS_StreamCreateFile(false, (const void*)file, 0, 0, BASS_SAMPLE_LOOP| BASS_UNICODE);
        long len = _BASS_ChannelGetLength(g_BassHandle, BASS_POS_BYTE);

GetAsUTF8 is a widechar to multibyte conversion, similar to WideCharToMultibyte(CP_UTF8...) function. Return value is const char*. It works perfect but it looks like the bass lib do not understand this UTF8 format. I use BASS_UNICODE as flag and expect that this works.
What I do wrong?


  • Posts: 15
Re: Bass and Unicode - How to
« Reply #1 on: 6 Apr '19 - 00:53 »
By default on Windows the encoding is ANSI, with the BASS_UNICODE flag it becomes UTF-16. I don't think UTF-8 is accepted on the Windows version at all.


BASS_UNICODE   file is in UTF-16 form. Otherwise it is ANSI on Windows or Windows CE, and UTF-8 on other platforms.