swiftlang / swift-corelibs-foundation

The Foundation Project, providing core utilities, internationalization, and OS independence
swift.org
Apache License 2.0
5.29k stars 1.13k forks source link

FileHandle works in variable text/binary mode by default #5105

Open jakepetroules opened 1 month ago

jakepetroules commented 1 month ago

See https://learn.microsoft.com/en-us/cpp/c-runtime-library/text-and-binary-mode-file-i-o?view=msvc-170

Constructors such as FileHandle.init(forReadingFrom:)should explicitly pass _O_BINARY to _openFileDescriptorForURL to control the translation mode; else the behavior is subject to the process global translation state, leading to inconsistent behavior.

jakepetroules commented 1 month ago

@compnerd Do you have any thoughts on how this should work?