Skip to content

win-api: Switch Windows -A apis to -W variants - #13810

Open
Dankirk wants to merge 8 commits into
obsproject:masterfrom
Dankirk:w-apis
Open

win-api: Switch Windows -A apis to -W variants#13810
Dankirk wants to merge 8 commits into
obsproject:masterfrom
Dankirk:w-apis

Conversation

@Dankirk

@Dankirk Dankirk commented Aug 20, 2026

Copy link
Copy Markdown

Description

Based on changes in #13749 (included in this pr) and further supports #13097
EDIT: The last 2 commits + the merge commit are new.

Change all remaining instances of Windows Ansi api usage to Wide variants.

Pre-encode format specifiers %ls and %S (capital S) of printf family using WideCharToMultiByte / MultiByteToWideChar and then %s (small s) instead

  • This is necessary because OBS doesn't set C runtime locale/encoding, so printf function family cannot know the target/source encoding for %ls and %S specifiers and thus will fail on anything non-ascii.
  • Addresses non-UTF8 / truncated content being saved in the logs.
  • Printing to console using these is still a problem, since OBS doesn't set encoding for console either. As result non-ascii may appear garbled, but this wasn't working earlier either, it's just may be garbled differently.

Motivation and Context

Based on discussions on #13097 to move away from A apis, so OBS doesn't need to deal with the ansi encodings.

How Has This Been Tested?

Tried opening and restarting with a scene with all source types active.
Could still check outputs to console.

Types of changes

  • Tweak (non-breaking change to improve existing functionality)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

Dankirk and others added 8 commits August 17, 2026 20:17
Match GetAppConfigPathPtr and os_get_path_ptr_internal file path
formatting with GetAppConfigPath and os_get_path_internal.
Empty/null strings return base path.

Remove arbitrary path length limit with dynamic allocation.
Use dynamically allocated paths instead of arbitrary static
allocations, that may not be fit long paths on all OSs.
Filepaths from Windows W apis get stored internally in UTF-8,
which may increase the bytes needed.

Changed some A api calls to W variants to support longer paths,
and to get them in supported encoding isntead of ansi code page.

Fix overflow in os_stat() when used with long filename.

Fix off-by-one length check in nvvfx-load sdk path.
Define FILENAME_MAX_LENGTH_UTF8 (_MAX_PATH * 3)
for storing utf-16 converted paths in utf-8 on Windows for cases
where dynamic allocation could may be performance issue and for
simplicity.

A UTF-16 code unit (wchar_t) can be up to 3 bytes/chars in UTF-8.

Change os_dirent filename to be char pointer, so it is OS agnostic
about the actual allocation size. It is also compiled in to
lua/python wraps, so we can't use platform specific defines.
Use W apis instead of A apis and as necessary convert to utf-8 only
from it to avoid dealing with other encodings.
OBS doesn't set C runtime locale so printf function family
cannot properly use format specifiers like %ls and %S (capital S)
to insert wide strings into narrow strings and vice versa.

Instead pre-encode inserted strings to narrow/wide using utf-8 as
the target/source encoding and use %s.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant