Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix locale on linux #15723

Merged
merged 1 commit into from
Jun 23, 2024
Merged

Fix locale on linux #15723

merged 1 commit into from
Jun 23, 2024

Conversation

MSuih
Copy link
Member

@MSuih MSuih commented Jun 23, 2024

When launching emulator on linux, the following line appears in console:

E CFG: cfg::try_to_float('0.000000'): invalid float

It happens because my systems locale uses comma as decimal separator while rpcs3 expects dot.

RPCS3 does try to set locale to C when launching:

rpcs3/rpcs3/main.cpp

Lines 86 to 91 in 7e27e14

// Let's initialize the locale first
static const bool s_init_locale = []()
{
std::setlocale(LC_ALL, "C");
return true;
}();

But Qt sets this back to system default as documented in here:

On Unix/Linux Qt is configured to use the system locale settings by default. This can cause a conflict when using POSIX functions, for instance, when converting between data types such as floats and strings, since the notation may differ between locales. To get around this problem, call the POSIX function setlocale(LC_NUMERIC,"C") right after initializing QApplication, QGuiApplication or QCoreApplication to reset the locale that is used for number formatting to "C"-locale.

This PR fixes the issue by changing locale back after application is initialized.

rpcs3/main.cpp Outdated Show resolved Hide resolved
@Megamouse Megamouse merged commit 7e274a1 into RPCS3:master Jun 23, 2024
6 checks passed
@MSuih MSuih deleted the locale branch June 23, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants