diff options
author | Abseil Team <absl-team@google.com> | 2020-05-19 02:04:38 (GMT) |
---|---|---|
committer | Derek Mauro <dmauro@google.com> | 2020-05-28 23:53:52 (GMT) |
commit | f3a59610fd1e5f123ad4593eb292fcceba37cc82 (patch) | |
tree | cd29f131233f874e2cd6fbdb5e6a747765448006 /googletest/include/gtest/internal | |
parent | a0669e070a441d8229eca5f6178ece4157413763 (diff) | |
download | googletest-f3a59610fd1e5f123ad4593eb292fcceba37cc82.zip googletest-f3a59610fd1e5f123ad4593eb292fcceba37cc82.tar.gz googletest-f3a59610fd1e5f123ad4593eb292fcceba37cc82.tar.bz2 |
Googletest export
Addresses https://github.com/google/googletest/issues/2848 by using `_wfopen(...)` on Windows
PiperOrigin-RevId: 312198825
Diffstat (limited to 'googletest/include/gtest/internal')
-rw-r--r-- | googletest/include/gtest/internal/gtest-port.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 893c7f3..0a3bf5e 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -269,6 +269,7 @@ #endif #include <iostream> // NOLINT +#include <locale> #include <memory> #include <string> // NOLINT #include <tuple> @@ -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<std::codecvt<wchar_t, char, std::mbstate_t>> 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) { |