I don’t quite understand what encoding the SDL functions (specifically SDL2 ) work with.
For example:
SDL_Surface *SDL_LoadBMP(const char *); const char *SDL_GetError(); Is it utf-8 ?
8-bit encoding in system locale?
Latin-1 ?
I don’t quite understand what encoding the SDL functions (specifically SDL2 ) work with.
For example:
SDL_Surface *SDL_LoadBMP(const char *); const char *SDL_GetError(); Is it utf-8 ?
8-bit encoding in system locale?
Latin-1 ?
Judging by the migration guide, one of the key changes was unicode support. All lines for text input events go to UTF-8. In addition, SDL_CreateWindow explicitly indicates what UTF-8 is expecting. Most likely the correct answer is UTF-8.
Why beat around the bush if we have the source ?
SDL_LoadBMP is a macro that passes a file to the SDL_RWFromFile function without changes.
In the function SDL_RWFromFile there is any different platform dependent code:
for Android, it is used whenever possible fopen, and if not, then Android_JNI_FileOpen , which uses the NewStringUTF function, which accepts some modified UTF-8 ;
for Windows, windows_file_open is used, which using the WIN_UTF8ToString macro (in which SDL_iconv_string) gets the Windows UTF-16LE string from the input UTF-8 encoded string;
for Apple systems, inside SDL_OpenFPFromBundleOrFallback , fopen is used, but there is no exact information about it, but the file system uses UTF-8;
for Windows RT, fopen_s is used, the exact information about the encoding of which I also did not find, but if it is similar to the fopen function, then the ANSI format is probably used;
for all other systems, file is transferred to fopen without changes, and the encoding depends on the platform and system settings, although in modern Unix-like operating systems this is most often UTF-8.
Thus, if I correctly interpreted the source code and documentation, the answer is obtained - it depends on the platform and build parameters .
It is possible that strictly other UTF-8 is used in other functions of the SDL that are not related to the file system, but apparently, you can pick up problems from just SDL_LoadBMP.
By the way, the SDL_RWFromFile documentation states that UTF-8 is used. It turns out, lying?
Source: https://ru.stackoverflow.com/questions/886055/
All Articles