You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when i try to open a mp3 file, which contains kyrilik letters.
(Win 11 System)
The text was updated successfully, but these errors were encountered:
PyGuK213
changed the title
'Could not load file' Error - using kyrilik letters in the filename
'Could not load file' Error (Win 11) - using kyrilik letters in the filename
Nov 26, 2023
I briefly looked into this problem and apparently if you want to open files with Unicode names on Windows using fopen, you must first convert them to UTF-16 (a.k.a. Wide Characters) and use _wfopen. Imgui had (still has?) a similar issue ocornut/imgui#917
Here I adapted an example on how to do that in pure C:
#include<assert.h>#include<stdio.h>#include<stdlib.h>#include<string.h>#defineWIN32_LEAN_AND_MEAN#include<windows.h>intmain(void)
{
constchar*file_path="F:\\nu11 wip works 2016-2022 (ogg)\\кириллик.ogg";
intfile_path_len=strlen(file_path);
intwide_path_len=MultiByteToWideChar(CP_UTF8, 0, file_path, file_path_len, NULL, 0);
wchar_t*wide_path= (wchar_t*)malloc((wide_path_len+1)*sizeof(wchar_t));
assert(wide_path!=NULL);
MultiByteToWideChar(CP_UTF8, 0, file_path, file_path_len, wide_path, wide_path_len);
wide_path[wide_path_len] =0;
FILE*f=_wfopen(wide_path, L"rb");
if (!f) {
printf("ERROR: could not open the file!\n");
return1;
}
printf("Successfully opened the file!\n");
return0;
}
It looks like a lot of external libraries that Raylib depends on simply use fopen which probably means there is no quick fix for this right now. Eventually I plan to dig deeper into each and individual dependency and see how to properly fix all of this.
For now I can only suggest to simply not use files that have any Unicode symbols in their paths. Maybe a quick stopgap solution could be to explain that to the user in the error message.
I get a:
when i try to open a mp3 file, which contains kyrilik letters.
(Win 11 System)
The text was updated successfully, but these errors were encountered: