fix(libc): convert the Windows time zone name from the ANSI code page to UTF-8 for tzname, %Z and tm_zone #10981

Closed
opened 2026-10-25 12:14:49 +00:00 by xXPBSXx · 0 comments
xXPBSXx commented 2026-10-25 12:14:49 +00:00 (Migrated from github.com)
Contributor

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_formatting fail on a German Windows 10 at main a5a780eaaa. 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).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6024321611 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/10981). Originally posted by [xXPBSXx](https://github.com/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_formatting` fail on a German Windows 10 at main a5a780eaaa. 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).
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#10981
No description provided.