mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
Enable non-ascii chars (#1669)
* Enable non-ascii chars * Follow file naming policy * Use stream read and write methods * Remove obsolete close() calls * Revert "Remove obsolete close() calls" This reverts commit7006bcb038. * Revert "Use stream read and write methods" This reverts commitec06a1a05b.
This commit is contained in:
@@ -9,11 +9,12 @@ namespace json
|
||||
{
|
||||
try
|
||||
{
|
||||
std::wifstream file(file_name.data(), std::ios::binary);
|
||||
std::ifstream file(file_name.data(), std::ios::binary);
|
||||
if (file.is_open())
|
||||
{
|
||||
using isbi = std::istreambuf_iterator<wchar_t>;
|
||||
return JsonValue::Parse(std::wstring{ isbi{ file }, isbi{} }).GetObjectW();
|
||||
using isbi = std::istreambuf_iterator<char>;
|
||||
std::string obj_str{ isbi{ file }, isbi{} };
|
||||
return JsonValue::Parse(winrt::to_hstring(obj_str)).GetObjectW();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -25,6 +26,7 @@ namespace json
|
||||
|
||||
void to_file(std::wstring_view file_name, const JsonObject& obj)
|
||||
{
|
||||
std::wofstream{ file_name.data(), std::ios::binary } << obj.Stringify().c_str();
|
||||
std::wstring obj_str{ obj.Stringify().c_str() };
|
||||
std::ofstream{ file_name.data(), std::ios::binary } << winrt::to_string(obj_str);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user