diff --git a/src/SaveTool/SaveTool_Initialisation.cpp b/src/SaveTool/SaveTool_Initialisation.cpp index e14bb2b..ba0441a 100644 --- a/src/SaveTool/SaveTool_Initialisation.cpp +++ b/src/SaveTool/SaveTool_Initialisation.cpp @@ -198,9 +198,17 @@ SaveTool::findGameDataDirectory() -> bool { wchar_t* localappdata_path = nullptr; Containers::ScopeGuard guard{localappdata_path, CoTaskMemFree}; - if(SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_NO_APPCONTAINER_REDIRECTION, nullptr, &localappdata_path) != S_OK) + auto result = SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_DEFAULT, nullptr, &localappdata_path); + if(result != S_OK) { - _lastError = Utility::format("SHGetKnownFolderPath() failed with error code {}.", GetLastError()); + char* message_buffer = nullptr; + auto size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, + nullptr, result, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), + reinterpret_cast(&message_buffer), 0, nullptr); + String message{message_buffer, size}; + LocalFree(message_buffer); + + _lastError = Utility::format("SHGetKnownFolderPath() failed with error code {}: {}", result, message); LOG_ERROR(_lastError); return false; } diff --git a/src/main.cpp b/src/main.cpp index 20e1be1..13e958c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -45,7 +45,7 @@ int main(int argc, char** argv) { Containers::StringView locale{str}; LOG_INFO_FORMAT("Current locale: {}", locale); - if(!locale.hasSuffix(".utf8")) { + if(!locale.hasSuffix(".utf8") && !locale.hasSuffix(".65001")) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", "Your system doesn't support UTF-8.", nullptr); return EXIT_FAILURE;