fix(libc): convert the Windows time zone name from the ANSI code page to UTF-8 for tzname, %Z and tm_zone #10981
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-25T12:14:49Z.
On a Windows host with a non-English language (for example German, where the name of Central European Time contains U+00E4), the C runtime reports the zone name in the ANSI code page (cp1252, byte 0xE4 for that character). The guest locale is UTF-8, so the guest gets an invalid sequence from the tzname array, from %Z of strftime and from tm_zone of localtime_s. wcsftime then fails on the conversion and returns 0 (strftime returns 37 characters for the same format), which makes
guest_wide_formattingfail on a German Windows 10 at maina5a780eaaa. On FreeBSD 11.4 the names come from the abbreviation strings stored in the zone file (tzfile header field tzh_charcnt) or from the TZ string, and libc does no code page conversion there.Proposed fix: convert the host zone name from the ANSI code page to UTF-8 where the guest receives it (tzname and tm_zone). If a name cannot be converted, the original is kept. The wide formatting test compared a byte count with a character count; it now compares the wide output with the UTF-8 decoded strftime output.
Measured on German Windows 10, same base
a5a780eaaa, build exit=0: wide formatting test 3 of 3 red before, 3 of 3 green after; the three other time tests still pass. Expected, not measured: on an English Windows the name is ASCII and nothing changes. Not measured: no English Windows and no Linux run, and no test with a fixed cp1252 byte string.AI-assisted (Claude Code).