Root cause: read_as_string(const openstudio::path& t_path) in src/utilities/core/FilesystemHelpers.cpp opened the file with openstudio::filesystem::ifstream f(t_path); — no std::ios_base::binary flag. On Windows this defaults to text mode, which translates \r\n → \n while reading.
The underlying read() helper computes file_len from tellg()/seekg() (the raw on-disk byte count) and then does a single t_file.read(&buf.front(), file_len). In text mode, the CRLF translation means fewer characters actually get read than the buffer was sized for, so the string gets truncated/corrupted with trailing garbage — silently, no error. This only manifests on Windows since POSIX has no text/binary distinction, which matches the "Windows and only Windows" symptom, and explains why parsing barreled all the way to line 8769 before choking on garbage.
The sibling function read(const path&) already correctly used std::ios_base::binary — the string-returning overload just missed it.
Fix: src/utilities/core/FilesystemHelpers.cpp:38 — added std::ios_base::binary to match.
Verified by rebuilding openstudio_utilities_tests and running:
- --gtest_filter=*EpwFile_UTF8BOM* → now passes
- --gtest_filter=Filetypes.* → all 63 tests pass, no regressions
Pull request overview
Root cause: read_as_string(const openstudio::path& t_path) in src/utilities/core/FilesystemHelpers.cpp opened the file with openstudio::filesystem::ifstream f(t_path); — no std::ios_base::binary flag. On Windows this defaults to text mode, which translates \r\n → \n while reading.
The underlying read() helper computes file_len from tellg()/seekg() (the raw on-disk byte count) and then does a single t_file.read(&buf.front(), file_len). In text mode, the CRLF translation means fewer characters actually get read than the buffer was sized for, so the string gets truncated/corrupted with trailing garbage — silently, no error. This only manifests on Windows since POSIX has no text/binary distinction, which matches the "Windows and only Windows" symptom, and explains why parsing barreled all the way to line 8769 before choking on garbage.
The sibling function read(const path&) already correctly used std::ios_base::binary — the string-returning overload just missed it.
Fix: src/utilities/core/FilesystemHelpers.cpp:38 — added std::ios_base::binary to match.
Pull Request Author
src/model/test)src/energyplus/Test)src/osversion/VersionTranslator.cpp)Labels:
IDDChangeAPIChangePull Request - Ready for CIso that CI builds your PRReview Checklist
This will not be exhaustively relevant to every PR.