diff --git a/src/settings.cpp b/src/settings.cpp index e59d9b1..d272768 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -154,9 +154,19 @@ DockSpace ID=0x123F8F08 Window=0x6D581B32 Pos=8,62 Size=1902,994 Spl dest = (val == "true" || val == "1"); } else if constexpr (std::is_same_v) + { std::getline(ss, dest); + } + else if constexpr (std::is_same_v) + { + std::string value; + std::getline(ss, value); + dest = path::from_utf8(value); + } else + { stream_assign(dest, ss); + } }; auto entry_load = @@ -324,6 +334,8 @@ DockSpace ID=0x123F8F08 Window=0x6D581B32 Pos=8,62 Size=1902,994 Spl if constexpr (std::is_same_v) file << key << "=" << (value ? "true" : "false") << "\n"; + else if constexpr (std::is_same_v) + file << key << "=" << path::to_utf8(value) << "\n"; else file << key << "=" << value << "\n"; }; diff --git a/src/util/process_.cpp b/src/util/process_.cpp index f3b9bf6..e494a44 100644 --- a/src/util/process_.cpp +++ b/src/util/process_.cpp @@ -1,7 +1,33 @@ #include "process_.h" +#ifdef WIN32 + #include + #include + #include +#endif + namespace anm2ed::util { +#ifdef WIN32 + namespace + { + std::wstring utf8_to_wstring(const char* string) + { + if (!string) return {}; + + auto requiredSize = MultiByteToWideChar(CP_UTF8, 0, string, -1, nullptr, 0); + if (requiredSize <= 0) return {}; + + std::wstring wide(static_cast(requiredSize), L'\0'); + MultiByteToWideChar(CP_UTF8, 0, string, -1, wide.data(), requiredSize); + + if (!wide.empty() && wide.back() == L'\0') wide.pop_back(); + + return wide; + } + } +#endif + Process::Process(const char* command, const char* mode) { open(command, mode); } Process::~Process() { close(); } @@ -11,7 +37,9 @@ namespace anm2ed::util close(); #ifdef WIN32 - pipe = _popen(command, mode); + auto wideCommand = utf8_to_wstring(command); + auto wideMode = utf8_to_wstring(mode); + pipe = _wpopen(wideCommand.c_str(), wideMode.c_str()); #else pipe = popen(command, mode); #endif @@ -52,4 +80,4 @@ namespace anm2ed::util FILE* Process::get() const { return pipe; } Process::operator bool() const { return pipe != nullptr; } -} \ No newline at end of file +}