From f3a59610fd1e5f123ad4593eb292fcceba37cc82 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 18 May 2020 22:04:38 -0400 Subject: [PATCH] Googletest export Addresses https://github.com/google/googletest/issues/2848 by using `_wfopen(...)` on Windows PiperOrigin-RevId: 312198825 --- googletest/include/gtest/internal/gtest-port.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 893c7f30..0a3bf5e4 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -269,6 +269,7 @@ #endif #include // NOLINT +#include #include #include // NOLINT #include @@ -2045,7 +2046,14 @@ GTEST_DISABLE_MSC_DEPRECATED_PUSH_() inline int ChDir(const char* dir) { return chdir(dir); } #endif inline FILE* FOpen(const char* path, const char* mode) { +#if GTEST_OS_WINDOWS + std::wstring_convert> converter; + std::wstring wide_path = converter.from_bytes(path); + std::wstring wide_mode = converter.from_bytes(mode); + return _wfopen(wide_path.c_str(), wide_mode.c_str()); +#else return fopen(path, mode); +#endif // GTEST_OS_WINDOWS } #if !GTEST_OS_WINDOWS_MOBILE inline FILE *FReopen(const char* path, const char* mode, FILE* stream) {