The documentation says that the String class internal representation of the data is in unicode (actual wchar_t is encoded in UCS-2 or UCS-4 dependend on the current os) or in ASCII. This is controlled by the JUCE_STRINGS_ARE_UNICODE-define. If the other representation is needed it will be converted from the internal one via mbstowcs or wcstombs. But these functions don’t convert between unicode and ASCII, but between unicode an the encoding of the current locale, which is by default the C locale. In the default case it’s right to say mbstowcs and wcstombs convert between unicode and ASCII, because the C locale uses ASCII.
On windows I didn’t have any problems with this, because JUCE and the part of the WinAPI concerning the filesystem communicate via unicode. But on linux JUCE uses these functions to produce strings i.e. for fopen. There is no problem until you have non-ASCII characters in your paths like ü, ö, ä, ß or something else. Then JUCE will fail to handle those paths correctly. It’s not JUCEs fault after all. I tooks me several hours to figure out that I need to set the locale via
to the current system-locale. In my case this includes UTF-8 as encoding on my ubuntu-box. So fopen expects a path encoded in UTF-8 rather than in ASCII. With the locale set to the system-locale wcstombs will convert unicode to UTF-8 and fopen and other functions related to this will be happy.
This leads to two suggestions I would make:
- In the documentation and in the code should not be refered to strings in locale-encoding as ASCII.
- The documentation should give a hint to set the locale to the system-local via setlocale(LC_CTYPE, “”) if problems with paths or something related to this occur on linux.