al_load_bitmap and unicode characters in filename
when I try to load images with unicode characters in the file name, it fails.
I did little digging, and found out, that the code should handle wide char conversion for the file name actually breaks it.
1static void *
file_stdio_fopen(const char *
path, const char *
7 wchar_t *
8 wchar_t *
fp = fopen(
17 if (!
When I changed the ifdef ALLEGRO_WINDOWS to #if 0 (sing the non-windows variant), it started working, and I could load those files.
I'm probably doing something the wrong way, but not sure what is it, I'm no expert of wide string/utf 8.
Then you're probably not providing a UTF-8 path. Sample code?
The part of the filename that contains invalid characteres (User name on windows, while accessing the User/<Username>/AppData/Roaming ...
3 TCHAR szPath[MAX_PATH];
5 if (SUCCEEDED(SHGetFolderPath(NULL,
6 CSIDL_APPDATA | CSIDL_FLAG_CREATE,
11 boost::filesystem::path result = boost::filesystem::path(szPath) / "Factorio";
13 return result;
16 throw std::runtime_error("Couldn't get application data directory");
Later I just make string out of the path (path / "preview image path").string() and send it to the allegro.
You can see, that boost has no problem with creating the directory that contains the unicode character.
.string() returns a std::string, you still need to convert it to a sequence of UTF-8 to pass it to al_load_bitmap()
Thread #612072. Printed from Allegro.cc
Also have to make sure its in UTF-8, rather than the UTF-16 that windows returns.