-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
frontend: Use system locale on Windows instead of 'C' #12624
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
base: master
Are you sure you want to change the base?
Conversation
Scouted the web and the codebase for potential issues. Here's some observations... General stuff about setlocale() on Windows
multibyte <-> utf8 <-> wcharIn platform.h there are various string conversion functions. From these only the multibyte functions with The The utf8 <-> wchar functions (ie Streams and file operationsC++ streams, like C-style
When to setlocale() ?The beginning of |
9d20b0c
to
c0dbe23
Compare
Sets runtime locale to system locale with UTF-8 codepage. This is already default behavior on unix, but Windows defaults to minimal 'C' locale. OBS Studio language settings no longer change QLocale default locale, instead system locale is used for conformity. It is likely this is what user wants as well. Ie. sorting and formatting functions should follow OS locale instead of OBS Studio language (which also lacks country information).
Cast ctype function char parameters to unsigned char to ensure they are in correct range (0 to 255 vs -128 to 127) when used with utf-8 encoding (or extended ascii). Fixes dstr astrcmp* functions when used with utf-8 (or extended ascii) characters, so now they are treated greater than the base ascii and thus sorted after them, not before.
Switch locale-aware timestamping for logging / crash handling to %H:%M:%S
Use CRT locale as default for C++. logfile and stdout/in/err streams still use the default minimal 'C'.
Description
Sets C runtime locale to system locale with UTF-8 codepage on Windows.
This has always been default behavior on unix, but Windows defaults to minimal 'C' locale.
LC_NUMERIC
is still set to"C"
. Now on all platforms instead of just unix.This is so decimal point is a dot (not a comma) for string <-> float conversions.
The configured CRT locale is copied to be the default
std::locale
for C++.All platforms have been using minimal
"C"
until now. This change affects newfacet
andios_base
instances without a specified locale orimbue()
call.OBS Studio language setting no longer changes
QLocale
's default locale and instead always uses system locale.This gives conformity with non Qt functions, but most importantly is likely what user wants as well. Ie. sorting and formatting functions should follow OS locale rules instead of OBS Studio translations language. (Reverts c4840dd)
obs_get_locale()
still returns OBS language locale, which is used for Python and LUA apis, GDI+ text widget transformations, and HTTP accepted languages header.Motivation and Context
Locale-aware operations like sorting and time formatting in C are not available on Windows, but are on unix, as pointed out in PR #12577.
Fixes #11133
The C++ locale and QLocale changes make the locale-aware functions of all layers work in similiar fashion.
For example: On unix currently the used locales are: OS locale for CRT, minimal
"C"
for C++ and OBS language for QLocale.A weekday name can be in three different languages depending if you used
strftime()
,std::time_get
facet orQLocale
.This makes string transformations between C, C++ and Qt very tricky.
How Has This Been Tested?
An important point is that the CRT locale settings have always been different for unix and Windows, which suggests there aren't any insurmountable problems with that change. Windows specific functions should be tested for CRT locale. Changes for C++ and QLocale defaults affect all platforms.
Searched the codebase for things and addressed as necessary:
strftime()
formatting with%
placeholdersscanf()
andprintf()
formatting with%
placeholdersFILE
operationsfstream
operationsfacet
locale usageQString
locale-aware methodsSome general testing with Japanese characters
I'm on Windows 11 English US version, but with Finnish locale settings (fi_FI). OBS language is English.
Types of changes
Checklist: