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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user