1
0
mirror of synced 2025-02-20 04:01:01 +01:00

fix: Data inspector causing crashes when failing to decode UTF-16 chars

This commit is contained in:
WerWolv 2021-09-10 15:25:42 +02:00
parent a8ed57bd65
commit 8657cf26de

View File

@ -109,7 +109,7 @@ namespace hex::plugin::builtin {
ContentRegistry::DataInspector::add("hex.builtin.inspector.wide", sizeof(wchar_t), [](auto buffer, auto endian, auto style) {
auto c = hex::changeEndianess(*reinterpret_cast<wchar_t*>(buffer.data()), endian);
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter("Invalid");
auto value = hex::format("'{0}'", c <= 255 ? makePrintable(c) : converter.to_bytes(c));
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };