frontend, libobs: Base work for localization and utf-8#13097
frontend, libobs: Base work for localization and utf-8#13097Dankirk wants to merge 3 commits intoobsproject:masterfrom
Conversation
|
If the manifest utf-8 declaration is deemed too risky (detailed this in "breaking change" section of the description), we could do the commandline argument parsing with |
PatTheMav
left a comment
There was a problem hiding this comment.
@RytoEX Was split off from the original PR. Changes to the time format (using fixed %F and %T) seem indeed more correct to me, and casting the character values to unsigned char to fit the expectations of the underlying functions is also correct to avoid triggering undefined behaviour.
The UTF-8 codepage change allows OBS' existing commandline argument parsing code to correctly handle arguments using non-ASCII characters on Windows, but will affect any call to an ANSI Windows API function (and indeed any call to a C library call) in turn.
c90f27b to
b87b403
Compare
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.
b87b403 to
a034c4f
Compare
RytoEX
left a comment
There was a problem hiding this comment.
Generally, I prefer the explicitness of %Y-%m-%d over the brevity of %F because I can immediately recognize the former while I have to look up the latter.
@PatTheMav Aside from the breaking items mentioned, is there anything else this would break?
Switch locale-aware timestamping for logging / crash handling to %H:%M:%S Update frontend/OBSApp.cpp Co-authored-by: Patrick Heyer <PatTheMav@users.noreply.github.com> Update libobs/obs-win-crash-handler.c Co-authored-by: Patrick Heyer <PatTheMav@users.noreply.github.com>
Declaring Utf-8 as active code page in manifest makes Win32 API use utf-8 instead of ANSI codepages when using the "A" versions of functions. Manifest declaration also encodes command line arguments as utf8. This allows for example --profile <name> to load profiles with special characters.
a034c4f to
017c69a
Compare
Description
Sets UTF-8 as active codepage for Windows in obs.manifest file.
This changes Windows APIs to use utf-8 for the A(nsi) functions instead of the language dependent ANSI codepage. The W(ide) functions are untouched and are still used by default since we use the UNICODE build flag. This also helps directing less encoding-aware 3rd party plugins and libraries towards a supported encoding.
Active codepage also encodes commandline arguments on Windows as utf-8, which allows for example
./obs64.exe --profile <name>to load profiles with special characters correctly.Change time formatting for logging to use ISO standard without localization to preserve logging format in different locales.
Casts ctype function parameters from
chartounsigned charto prevent non-ascii input from crashing them. Functions expect parameters to be in 0-255 range, which char using utf-8 casted to int might not be (signed char range is -128 to 127)Motivation and Context
This is based on discussion PR #12624 and split from the main issue there.
This serves as ground work for enabling localization and handling utf-8 data with C APIs
How Has This Been Tested?
Tested active code page effect by naming a scene with some Japanese characters, selecting another scene so it's not opened by default on restart and then restarting the app with command line
./obs64.exe --scene <japanese characters>This wasn't working in current version on Windows.
Types of changes
MultiByteToWideChar()withCP_ACPflag (using other flag may have been broken, but if it was CP_UTF8 it is now fixed)Checklist: