diff --git a/CHANGELOG.md b/CHANGELOG.md index 88852b8..a708dc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ template: - fixed null pointer dereference in parser when exceptions are disabled (#169) (@ncaklovic) - fixed spurious warnings in MSVC 19.34 - fixed some `_Float16` detection issues +- fixed `toml::parse_file()` on windows for non-ASCII paths

diff --git a/include/toml++/impl/parser.inl b/include/toml++/impl/parser.inl index ad4aeaa..7aa9afb 100644 --- a/include/toml++/impl/parser.inl +++ b/include/toml++/impl/parser.inl @@ -3762,7 +3762,11 @@ TOML_ANON_NAMESPACE_START std::ifstream file; TOML_OVERALIGNED char file_buffer[sizeof(void*) * 1024u]; file.rdbuf()->pubsetbuf(file_buffer, sizeof(file_buffer)); +#if TOML_WINDOWS + file.open(impl::widen(file_path_str), std::ifstream::in | std::ifstream::binary | std::ifstream::ate); +#else file.open(file_path_str, std::ifstream::in | std::ifstream::binary | std::ifstream::ate); +#endif if (!file.is_open()) TOML_PARSE_FILE_ERROR("File could not be opened for reading", file_path_str); diff --git a/include/toml++/impl/std_string.inl b/include/toml++/impl/std_string.inl index 78a47cc..e288048 100644 --- a/include/toml++/impl/std_string.inl +++ b/include/toml++/impl/std_string.inl @@ -11,7 +11,7 @@ #endif //# }} -#if TOML_ENABLE_WINDOWS_COMPAT +#if TOML_WINDOWS #include "std_string.h" #ifndef _WINDOWS_ #if TOML_INCLUDE_WINDOWS_H @@ -96,4 +96,4 @@ TOML_IMPL_NAMESPACE_START TOML_IMPL_NAMESPACE_END; #include "header_end.h" -#endif // TOML_ENABLE_WINDOWS_COMPAT +#endif // TOML_WINDOWS diff --git a/toml.hpp b/toml.hpp index 44598c4..f1a7c14 100644 --- a/toml.hpp +++ b/toml.hpp @@ -9690,7 +9690,7 @@ TOML_POP_WARNINGS; //******** impl/std_string.inl *************************************************************************************** -#if TOML_ENABLE_WINDOWS_COMPAT +#if TOML_WINDOWS #ifndef _WINDOWS_ #if TOML_INCLUDE_WINDOWS_H @@ -9789,7 +9789,7 @@ TOML_IMPL_NAMESPACE_END; #endif TOML_POP_WARNINGS; -#endif // TOML_ENABLE_WINDOWS_COMPAT +#endif // TOML_WINDOWS //******** impl/print_to_stream.inl ********************************************************************************** @@ -15730,7 +15730,11 @@ TOML_ANON_NAMESPACE_START std::ifstream file; TOML_OVERALIGNED char file_buffer[sizeof(void*) * 1024u]; file.rdbuf()->pubsetbuf(file_buffer, sizeof(file_buffer)); +#if TOML_WINDOWS + file.open(impl::widen(file_path_str), std::ifstream::in | std::ifstream::binary | std::ifstream::ate); +#else file.open(file_path_str, std::ifstream::in | std::ifstream::binary | std::ifstream::ate); +#endif if (!file.is_open()) TOML_PARSE_FILE_ERROR("File could not be opened for reading", file_path_str);