Skip to content

Conversation

@kellemar
Copy link

Description
Added os_strftime_utf8() to handle strftime correctly on Windows. The existing strftime() calls in os_generate_formatted_filename() now use this new function.

On Windows, strftime() returns strings in the system's ANSI codepage rather than UTF-8. The new function uses wcsftime() and converts to UTF-8 properly.

Motivation and Context
Fixes #12953

Using %Z (timezone name) in the filename format crashes OBS on German Windows because the timezone "Mitteleuropäische Zeit" contains an umlaut. The ANSI-encoded string gets passed to os_fopen() which expects UTF-8, causing MultiByteToWideChar to fail.

Same issue would happen with any locale that has non-ASCII characters in timezone names or other strftime output.

How Has This Been Tested?
I don't have a German Windows installation to test directly. The fix follows the same pattern OBS already uses elsewhere for Windows string handling (wcs functions + os_wcs_to_utf8).

Would appreciate if someone with a German Windows setup could verify.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

@Dankirk
Copy link

Dankirk commented Dec 28, 2025

I have looked into locales and character encodings a bit and have a pull request here #12624 that also fixes this. I can confirm the crash does happen on Windows with settings set to German and that this PR would also fix that.

The timezone name is a bit interesting though, since with our current OBS locale being minimal 'C' on Windows (and not the system locale), the %Z flag is still translated using the Windows display language. This only happens with %Z flag, for example %A (weekday name) properly follows locale settings ('C') and thus is always in English, even on German display language, locale and region.

@PatTheMav
Copy link
Member

Could you please sync with @Dankirk whether this PR supersedes (or is superseded) by the PR(s) that already exist for this topic?

It would be great for reviewers to understand which PR they should prioritise.

@Dankirk
Copy link

Dankirk commented Jan 27, 2026

#12624 covers more. This method would still work if OS failed to set utf-8 C runtime locale, but it has been supported since Windows 10 v1803 (released in April 30, 2018).

@PatTheMav
Copy link
Member

#12624 covers more. This method would still work if OS failed to set utf-8 C runtime locale, but it has been supported since Windows 10 v1803 (released in April 30, 2018).

@kellemar do you agree with that? Would you be willing to look over that PR possibly leave comments so it addresses your concerns?

In that case we could focus on getting that one reviewed instead.

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.

OBS crashes if filename contains german Umlaut

3 participants