1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-26 08:14:38 +01:00

Json: Fix wrong implicit path typecasts in ReadFromFile and WriteToFile

These functions accepted fs::path which meant passing a u8string to them
wrongly assumed an ANSI encoding and not UTF-8. This would be
a non-issue in C++20 where char8_t is separate, but until then it was an issue
causing incorrect character conversions, and thus an exception.
This commit is contained in:
Silent
2022-02-12 14:13:47 +01:00
parent 46deac8620
commit 4621cc4264
3 changed files with 11 additions and 25 deletions

View File

@@ -283,7 +283,7 @@ void ShortcutManager::LoadLegacyBindings(const fs::path& path)
void ShortcutManager::LoadUserBindings(const fs::path& path)
{
auto root = Json::ReadFromFile(path);
auto root = Json::ReadFromFile(path.u8string());
if (root.is_object())
{
for (auto it = root.begin(); it != root.end(); ++it)
@@ -329,7 +329,7 @@ void ShortcutManager::SaveUserBindings(const fs::path& path)
json_t root;
if (fs::exists(path))
{
root = Json::ReadFromFile(path);
root = Json::ReadFromFile(path.u8string());
}
for (const auto& shortcut : Shortcuts)
@@ -349,7 +349,7 @@ void ShortcutManager::SaveUserBindings(const fs::path& path)
}
}
Json::WriteToFile(path, root);
Json::WriteToFile(path.u8string(), root);
}
std::string_view ShortcutManager::GetLegacyShortcutId(size_t index)