We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4954

Summary: SDL_Init() with SDL_INIT_GAMECONTROLLER flag changes locale
Product: SDL Reporter: Roman Shuvalov <roman>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: don't know   
Hardware: x86_64   
OS: macOS 10.15   

Description Roman Shuvalov 2020-01-18 15:46:00 UTC
On macOS, calling SDL_Init with SDL_INIT_GAMECONTROLLER flag affects locale. In my case it sets to system locale.

Minimal program to reproduce error:

----------------------------------------
#include <stdio.h>
#include <locale.h>
#include <SDL2/SDL.h>

int main(int argc, char** argv) {
    printf("%.2f | %s\n", 2.78, setlocale(LC_ALL, NULL));
    int sdl_init_result = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER);
    printf("%.2f | %s\n", 2.78, setlocale(LC_ALL, NULL));
}
---------------------------------------

Results:
2.78 | C
2,78 | ru_RU.UTF-8

On Linux locale remains ā€œCā€, on macOS, as you can see, it changes to ru_RU.UTF-8 and so decimal delimiter changes to ā€˜,’ which is not good.
Comment 1 Sam Lantinga 2020-01-18 18:50:33 UTC
This is fixed for 2.0.12. You can grab a preview here:
http://www.libsdl.org/tmp/SDL-2.0.zip

Thanks!
Comment 2 Roman Shuvalov 2020-02-23 23:37:34 UTC
Just noticed that locale is also changed on gamepad connect/disconnect and/or SDL_GameControllerOpen/SDL_GameControllerClose. Tested only on old version, don't know if this behavior has already been fixed in 2.0.12 as well as initial bug related to SDL_Init(SDL_INIT_GAMECONTROLLER).
Comment 3 Sam Lantinga 2020-03-02 02:08:01 UTC
Yes, this has been fixed. Please test on the latest code before reopening a bug.

Thanks!