http://bugs.winehq.org/show_bug.cgi?id=60000 Bug ID: 60000 Summary: msvcrt: fopen("wb, ccs=UTF-8") prepends a BOM unlike Windows Product: Wine Version: 11.13 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: msvcrt Assignee: wine-bugs@list.winehq.org Reporter: brandowlucas@gmail.com Target Milestone: --- Distribution: --- Created attachment 81407 --> http://bugs.winehq.org/attachment.cgi?id=81407 +msvcrt,+file I originally hit this in a fitgirl repack installer post-processing path. The affected program writes a binary intermediate file using: fopen(path, "wb, ccs=UTF-8") Wine prepends EF BB BF to the file even though the mode explicitly includes b. This shifts the binary stream and breaks its next consumer. I reduced it to a data-free CRT test, so the issue is not specific to that application. Reproducer: https://github.com/BrandowLucas/wine_msvcrt_binary_ccs_utf8_bom_reproducer That repository contains the source, prebuilt test executable, Windows/Wine logs, and the candidate patch I tested. Native Windows result: write_complete | path=... mode=wb,ccs=UTF-8 payload_size=4 bytes | path=... count=4 hex=00002274 Unpatched Wine result: write_complete | path=... mode=wb,ccs=UTF-8 payload_size=4 bytes | path=... count=7 hex=efbbbf00002274 Patched Wine result: write_complete | path=... mode=wb,ccs=UTF-8 payload_size=4 bytes | path=... count=4 hex=00002274 The relevant Wine code is dlls/msvcrt/file.c:_wsopen_dispatch(). It writes utf8_bom whenever _O_U8TEXT is present, without accounting for _O_BINARY. The patch that made the reproducer match Windows locally is in the repo: https://github.com/BrandowLucas/wine_msvcrt_binary_ccs_utf8_bom_reproducer/b... It writes the UTF-8 BOM only for non-binary UTF-8 streams and adds a regression test. Validation after the patch: - msvcrt file test: 1120 tests, 0 failures - ucrtbase file test: 504 tests, 0 failures - clean probe output matches Windows Reference: fopen/_wfopen documentation, including b mapping to _O_BINARY: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfop... Possibly related bug: https://bugs.winehq.org/show_bug.cgi?id=38909 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.