feat: Fixed string/char names in data inspector, added utf16 and utf32 string and char types
This commit is contained in:
parent
a83610bc06
commit
bff9b8b4b1
@ -94,7 +94,7 @@
|
||||
"hex.builtin.inspector.rgba8": "RGBA8 Farbe",
|
||||
"hex.builtin.inspector.sleb128": "Signed LEB128",
|
||||
"hex.builtin.inspector.string": "String",
|
||||
"hex.builtin.inspector.string16": "Wide String",
|
||||
"hex.builtin.inspector.wstring": "Wide String",
|
||||
"hex.builtin.inspector.time": "time_t",
|
||||
"hex.builtin.inspector.time32": "time32_t",
|
||||
"hex.builtin.inspector.time64": "time64_t",
|
||||
@ -106,7 +106,7 @@
|
||||
"hex.builtin.inspector.u8": "uint8_t",
|
||||
"hex.builtin.inspector.uleb128": "Unsigned LEB128",
|
||||
"hex.builtin.inspector.utf8": "UTF-8 code point",
|
||||
"hex.builtin.inspector.wide": "Wide Character",
|
||||
"hex.builtin.inspector.wide": "wchar_t",
|
||||
"hex.builtin.layouts.default": "Standard",
|
||||
"hex.builtin.layouts.none.restore_default": "Standard-Layout wiederherstellen",
|
||||
"hex.builtin.menu.edit": "Bearbeiten",
|
||||
|
@ -97,7 +97,9 @@
|
||||
"hex.builtin.inspector.rgba8": "RGBA8 Color",
|
||||
"hex.builtin.inspector.sleb128": "Signed LEB128",
|
||||
"hex.builtin.inspector.string": "String",
|
||||
"hex.builtin.inspector.string16": "Wide String",
|
||||
"hex.builtin.inspector.wstring": "Wide String",
|
||||
"hex.builtin.inspector.string16": "String16",
|
||||
"hex.builtin.inspector.string32": "String32",
|
||||
"hex.builtin.inspector.time": "time_t",
|
||||
"hex.builtin.inspector.time32": "time32_t",
|
||||
"hex.builtin.inspector.time64": "time64_t",
|
||||
@ -109,7 +111,9 @@
|
||||
"hex.builtin.inspector.u8": "uint8_t",
|
||||
"hex.builtin.inspector.uleb128": "Unsigned LEB128",
|
||||
"hex.builtin.inspector.utf8": "UTF-8 code point",
|
||||
"hex.builtin.inspector.wide": "Wide Character",
|
||||
"hex.builtin.inspector.wide": "wchar_t",
|
||||
"hex.builtin.inspector.char16": "char16_t",
|
||||
"hex.builtin.inspector.char32": "char32_t",
|
||||
"hex.builtin.layouts.default": "Default",
|
||||
"hex.builtin.layouts.none.restore_default": "Restore default layout",
|
||||
"hex.builtin.menu.edit": "Edit",
|
||||
|
@ -94,7 +94,7 @@
|
||||
"hex.builtin.inspector.rgba8": "Color RGBA8",
|
||||
"hex.builtin.inspector.sleb128": "LEB128 con Signo",
|
||||
"hex.builtin.inspector.string": "Cadena ",
|
||||
"hex.builtin.inspector.string16": "Cadena (wide)",
|
||||
"hex.builtin.inspector.wstring": "Cadena (wide)",
|
||||
"hex.builtin.inspector.time": "time_t",
|
||||
"hex.builtin.inspector.time32": "time32_t",
|
||||
"hex.builtin.inspector.time64": "time64_t",
|
||||
@ -106,7 +106,7 @@
|
||||
"hex.builtin.inspector.u8": "",
|
||||
"hex.builtin.inspector.uleb128": "LEB128 sin Signo",
|
||||
"hex.builtin.inspector.utf8": "Código UTF-8",
|
||||
"hex.builtin.inspector.wide": "Carácter (wide)",
|
||||
"hex.builtin.inspector.wide": "wchar_t",
|
||||
"hex.builtin.layouts.default": "Por defecto",
|
||||
"hex.builtin.layouts.none.restore_default": "",
|
||||
"hex.builtin.menu.edit": "Editar",
|
||||
|
@ -94,7 +94,7 @@
|
||||
"hex.builtin.inspector.rgba8": "RGBA8 Szín",
|
||||
"hex.builtin.inspector.sleb128": "Előjeles LEB128",
|
||||
"hex.builtin.inspector.string": "String",
|
||||
"hex.builtin.inspector.string16": "Széles string",
|
||||
"hex.builtin.inspector.wstring": "Széles string",
|
||||
"hex.builtin.inspector.time": "time_t",
|
||||
"hex.builtin.inspector.time32": "time32_t",
|
||||
"hex.builtin.inspector.time64": "time64_t",
|
||||
@ -106,7 +106,7 @@
|
||||
"hex.builtin.inspector.u8": "uint8_t",
|
||||
"hex.builtin.inspector.uleb128": "Előjeletlen LEB128",
|
||||
"hex.builtin.inspector.utf8": "UTF-8 kód pont",
|
||||
"hex.builtin.inspector.wide": "Széles karakter",
|
||||
"hex.builtin.inspector.wide": "wchar_t",
|
||||
"hex.builtin.layouts.default": "Alapértelmezett",
|
||||
"hex.builtin.layouts.none.restore_default": "Alapértelmezett elrendezés visszaállítása",
|
||||
"hex.builtin.menu.edit": "Szerkesztés",
|
||||
|
@ -94,7 +94,7 @@
|
||||
"hex.builtin.inspector.rgba8": "Colori RGBA8",
|
||||
"hex.builtin.inspector.sleb128": "",
|
||||
"hex.builtin.inspector.string": "String",
|
||||
"hex.builtin.inspector.string16": "Wide String",
|
||||
"hex.builtin.inspector.wstring": "Wide String",
|
||||
"hex.builtin.inspector.time": "time_t",
|
||||
"hex.builtin.inspector.time32": "time32_t",
|
||||
"hex.builtin.inspector.time64": "time64_t",
|
||||
@ -106,7 +106,7 @@
|
||||
"hex.builtin.inspector.u8": "uint8_t",
|
||||
"hex.builtin.inspector.uleb128": "",
|
||||
"hex.builtin.inspector.utf8": "UTF-8 code point",
|
||||
"hex.builtin.inspector.wide": "Wide Character",
|
||||
"hex.builtin.inspector.wide": "wchar_t",
|
||||
"hex.builtin.layouts.default": "Default",
|
||||
"hex.builtin.layouts.none.restore_default": "",
|
||||
"hex.builtin.menu.edit": "Modifica",
|
||||
|
@ -94,7 +94,7 @@
|
||||
"hex.builtin.inspector.rgba8": "RGBA8 Color",
|
||||
"hex.builtin.inspector.sleb128": "",
|
||||
"hex.builtin.inspector.string": "String",
|
||||
"hex.builtin.inspector.string16": "Wide String",
|
||||
"hex.builtin.inspector.wstring": "Wide String",
|
||||
"hex.builtin.inspector.time": "time_t",
|
||||
"hex.builtin.inspector.time32": "time32_t",
|
||||
"hex.builtin.inspector.time64": "time64_t",
|
||||
@ -106,7 +106,7 @@
|
||||
"hex.builtin.inspector.u8": "uint8_t",
|
||||
"hex.builtin.inspector.uleb128": "",
|
||||
"hex.builtin.inspector.utf8": "UTF-8 code point",
|
||||
"hex.builtin.inspector.wide": "Wide Character",
|
||||
"hex.builtin.inspector.wide": "wchar_t",
|
||||
"hex.builtin.layouts.default": "標準",
|
||||
"hex.builtin.layouts.none.restore_default": "",
|
||||
"hex.builtin.menu.edit": "編集",
|
||||
|
@ -94,7 +94,7 @@
|
||||
"hex.builtin.inspector.rgba8": "RGBA8 색상",
|
||||
"hex.builtin.inspector.sleb128": "부호 있는 LEB128",
|
||||
"hex.builtin.inspector.string": "문자열",
|
||||
"hex.builtin.inspector.string16": "와이드 문자열",
|
||||
"hex.builtin.inspector.wstring": "와이드 문자열",
|
||||
"hex.builtin.inspector.time": "time_t",
|
||||
"hex.builtin.inspector.time32": "time32_t",
|
||||
"hex.builtin.inspector.time64": "time64_t",
|
||||
@ -106,7 +106,7 @@
|
||||
"hex.builtin.inspector.u8": "uint8_t",
|
||||
"hex.builtin.inspector.uleb128": "부호 없는 LEB128",
|
||||
"hex.builtin.inspector.utf8": "UTF-8 코드 포인트",
|
||||
"hex.builtin.inspector.wide": "와이드 문자",
|
||||
"hex.builtin.inspector.wide": "wchar_t",
|
||||
"hex.builtin.layouts.default": "기본",
|
||||
"hex.builtin.layouts.none.restore_default": "기본 레이아웃 복원",
|
||||
"hex.builtin.menu.edit": "편집",
|
||||
|
@ -94,7 +94,7 @@
|
||||
"hex.builtin.inspector.rgba8": "RGBA8 Color",
|
||||
"hex.builtin.inspector.sleb128": "",
|
||||
"hex.builtin.inspector.string": "String",
|
||||
"hex.builtin.inspector.string16": "Wide String",
|
||||
"hex.builtin.inspector.wstring": "Wide String",
|
||||
"hex.builtin.inspector.time": "time_t",
|
||||
"hex.builtin.inspector.time32": "time32_t",
|
||||
"hex.builtin.inspector.time64": "time64_t",
|
||||
@ -106,7 +106,7 @@
|
||||
"hex.builtin.inspector.u8": "uint8_t",
|
||||
"hex.builtin.inspector.uleb128": "",
|
||||
"hex.builtin.inspector.utf8": "UTF-8 code point",
|
||||
"hex.builtin.inspector.wide": "Wide Character",
|
||||
"hex.builtin.inspector.wide": "wchar_t",
|
||||
"hex.builtin.layouts.default": "Default",
|
||||
"hex.builtin.layouts.none.restore_default": "",
|
||||
"hex.builtin.menu.edit": "Editar",
|
||||
|
@ -96,7 +96,7 @@
|
||||
"hex.builtin.inspector.rgba8": "RGBA8 цвет",
|
||||
"hex.builtin.inspector.sleb128": "Знаковый LEB128",
|
||||
"hex.builtin.inspector.string": "Строка",
|
||||
"hex.builtin.inspector.string16": "Wide строка",
|
||||
"hex.builtin.inspector.wstring": "Wide строка",
|
||||
"hex.builtin.inspector.time": "time_t",
|
||||
"hex.builtin.inspector.time32": "time32_t",
|
||||
"hex.builtin.inspector.time64": "time64_t",
|
||||
@ -108,7 +108,7 @@
|
||||
"hex.builtin.inspector.u8": "uint8_t",
|
||||
"hex.builtin.inspector.uleb128": "Беззнаковый LEB128",
|
||||
"hex.builtin.inspector.utf8": "UTF-8 код",
|
||||
"hex.builtin.inspector.wide": "Wide символ",
|
||||
"hex.builtin.inspector.wide": "wchar_t",
|
||||
"hex.builtin.layouts.default": "По умолчанию",
|
||||
"hex.builtin.layouts.none.restore_default": "Восстановить макет по умолчанию",
|
||||
"hex.builtin.menu.edit": "Правка",
|
||||
|
@ -123,7 +123,7 @@
|
||||
"hex.builtin.inspector.rgba8": "RGBA8 颜色",
|
||||
"hex.builtin.inspector.sleb128": "有符号LEB128",
|
||||
"hex.builtin.inspector.string": "字符串",
|
||||
"hex.builtin.inspector.string16": "宽字符串",
|
||||
"hex.builtin.inspector.wstring": "宽字符串",
|
||||
"hex.builtin.inspector.time": "time_t",
|
||||
"hex.builtin.inspector.time32": "time32_t",
|
||||
"hex.builtin.inspector.time64": "time64_t",
|
||||
@ -135,7 +135,7 @@
|
||||
"hex.builtin.inspector.u8": "uint8_t",
|
||||
"hex.builtin.inspector.uleb128": "无符号LEB128",
|
||||
"hex.builtin.inspector.utf8": "UTF-8 码位",
|
||||
"hex.builtin.inspector.wide": "宽字符",
|
||||
"hex.builtin.inspector.wide": "wchar_t",
|
||||
"hex.builtin.layouts.default": "默认",
|
||||
"hex.builtin.layouts.none.restore_default": "恢复默认布局",
|
||||
"hex.builtin.menu.edit": "编辑",
|
||||
|
@ -94,7 +94,7 @@
|
||||
"hex.builtin.inspector.rgba8": "RGBA8 顏色",
|
||||
"hex.builtin.inspector.sleb128": "有號數 LEB128",
|
||||
"hex.builtin.inspector.string": "字串",
|
||||
"hex.builtin.inspector.string16": "寬字串",
|
||||
"hex.builtin.inspector.wstring": "寬字串",
|
||||
"hex.builtin.inspector.time": "time_t",
|
||||
"hex.builtin.inspector.time32": "time32_t",
|
||||
"hex.builtin.inspector.time64": "time64_t",
|
||||
@ -106,7 +106,7 @@
|
||||
"hex.builtin.inspector.u8": "uint8_t",
|
||||
"hex.builtin.inspector.uleb128": "無號數 LEB128",
|
||||
"hex.builtin.inspector.utf8": "UTF-8 code point",
|
||||
"hex.builtin.inspector.wide": "框字元",
|
||||
"hex.builtin.inspector.wide": "wchar_t",
|
||||
"hex.builtin.layouts.default": "預設",
|
||||
"hex.builtin.layouts.none.restore_default": "還原預設版面配置",
|
||||
"hex.builtin.menu.edit": "編輯",
|
||||
|
@ -363,16 +363,73 @@ namespace hex::plugin::builtin {
|
||||
|
||||
auto c = hex::changeEndianness(wideChar, endian);
|
||||
|
||||
auto value = hex::format("{0}", c <= 255 ? makePrintable(c) : wolv::util::wstringToUtf8(std::wstring(&c, 1)));
|
||||
auto value = hex::format("{0}", c <= 255 ? makePrintable(c) : wolv::util::wstringToUtf8(std::wstring(&c, 1)).value_or("???"));
|
||||
return [value] { ImGuiExt::TextFormatted("'{0}'", value.c_str()); return value; };
|
||||
},
|
||||
[](const std::string &value, std::endian endian) -> std::vector<u8> {
|
||||
std::vector<u8> bytes;
|
||||
auto wideString = wolv::util::utf8ToWstring(value.c_str(), "");
|
||||
if (wideString.empty()) return bytes;
|
||||
auto wideString = wolv::util::utf8ToWstring(value.c_str());
|
||||
if (!wideString.has_value())
|
||||
return bytes;
|
||||
|
||||
bytes.resize(wideString.size() * sizeof(wchar_t));
|
||||
std::memcpy(bytes.data(), wideString.data(), bytes.size());
|
||||
bytes.resize(wideString->size() * sizeof(wchar_t));
|
||||
std::memcpy(bytes.data(), wideString->data(), bytes.size());
|
||||
|
||||
if (endian != std::endian::native)
|
||||
std::reverse(bytes.begin(), bytes.end());
|
||||
|
||||
return bytes;
|
||||
}
|
||||
);
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.char16", sizeof(char16_t),
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
std::ignore = style;
|
||||
|
||||
char16_t wideChar = '\x00';
|
||||
std::memcpy(&wideChar, buffer.data(), std::min(sizeof(char16_t), buffer.size()));
|
||||
|
||||
auto c = hex::changeEndianness(wideChar, endian);
|
||||
|
||||
auto value = hex::format("{0}", c <= 255 ? makePrintable(c) : wolv::util::utf16ToUtf8(std::u16string(&c, 1)).value_or("???"));
|
||||
return [value] { ImGuiExt::TextFormatted("'{0}'", value.c_str()); return value; };
|
||||
},
|
||||
[](const std::string &value, std::endian endian) -> std::vector<u8> {
|
||||
std::vector<u8> bytes;
|
||||
auto wideString = wolv::util::utf8ToUtf16(value);
|
||||
if (!wideString.has_value())
|
||||
return bytes;
|
||||
|
||||
bytes.resize(wideString->size() * sizeof(char16_t));
|
||||
std::memcpy(bytes.data(), wideString->data(), bytes.size());
|
||||
|
||||
if (endian != std::endian::native)
|
||||
std::reverse(bytes.begin(), bytes.end());
|
||||
|
||||
return bytes;
|
||||
}
|
||||
);
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.char32", sizeof(char32_t),
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
std::ignore = style;
|
||||
|
||||
char32_t wideChar = '\x00';
|
||||
std::memcpy(&wideChar, buffer.data(), std::min(sizeof(char32_t), buffer.size()));
|
||||
|
||||
auto c = hex::changeEndianness(wideChar, endian);
|
||||
|
||||
auto value = hex::format("{0}", c <= 255 ? makePrintable(c) : wolv::util::utf32ToUtf8(std::u32string(&c, 1)).value_or("???"));
|
||||
return [value] { ImGuiExt::TextFormatted("'{0}'", value.c_str()); return value; };
|
||||
},
|
||||
[](const std::string &value, std::endian endian) -> std::vector<u8> {
|
||||
std::vector<u8> bytes;
|
||||
auto wideString = wolv::util::utf8ToUtf32(value);
|
||||
if (!wideString.has_value())
|
||||
return bytes;
|
||||
|
||||
bytes.resize(wideString->size() * sizeof(char32_t));
|
||||
std::memcpy(bytes.data(), wideString->data(), bytes.size());
|
||||
|
||||
if (endian != std::endian::native)
|
||||
std::reverse(bytes.begin(), bytes.end());
|
||||
@ -439,7 +496,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
);
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.string16", 2,
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.wstring", sizeof(wchar_t),
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
std::ignore = buffer;
|
||||
std::ignore = endian;
|
||||
@ -450,17 +507,15 @@ namespace hex::plugin::builtin {
|
||||
std::string value, copyValue;
|
||||
|
||||
if (currSelection.has_value()) {
|
||||
std::u16string stringBuffer(std::min<size_t>(currSelection->size, 0x1000), 0x00);
|
||||
std::wstring stringBuffer(std::min<size_t>(currSelection->size * sizeof(wchar_t), 0x1000), 0x00);
|
||||
ImHexApi::Provider::get()->read(currSelection->address, stringBuffer.data(), stringBuffer.size());
|
||||
|
||||
for (auto &c : stringBuffer)
|
||||
c = hex::changeEndianness(c, endian);
|
||||
|
||||
auto it = std::remove_if(buffer.begin(), buffer.end(),
|
||||
[](auto c) { return c == 0x00; });
|
||||
buffer.erase(it, buffer.end());
|
||||
std::erase_if(buffer, [](auto c) { return c == 0x00; });
|
||||
|
||||
auto string = wolv::util::utf16ToUtf8(stringBuffer, "Invalid");
|
||||
auto string = wolv::util::wstringToUtf8(stringBuffer).value_or("Invalid");
|
||||
value = copyValue = hex::encodeByteString({ string.begin(), string.end() });
|
||||
|
||||
if (value.size() > MaxStringLength) {
|
||||
@ -481,6 +536,86 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
);
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.string16", sizeof(char16_t),
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
std::ignore = buffer;
|
||||
std::ignore = endian;
|
||||
std::ignore = style;
|
||||
|
||||
auto currSelection = ImHexApi::HexEditor::getSelection();
|
||||
|
||||
std::string value, copyValue;
|
||||
|
||||
if (currSelection.has_value()) {
|
||||
std::u16string stringBuffer(std::min<size_t>(currSelection->size * sizeof(char16_t), 0x1000), 0x00);
|
||||
ImHexApi::Provider::get()->read(currSelection->address, stringBuffer.data(), stringBuffer.size());
|
||||
|
||||
for (auto &c : stringBuffer)
|
||||
c = hex::changeEndianness(c, endian);
|
||||
|
||||
std::erase_if(buffer, [](auto c) { return c == 0x00; });
|
||||
|
||||
auto string = wolv::util::utf16ToUtf8(stringBuffer).value_or("Invalid");
|
||||
value = copyValue = hex::encodeByteString({ string.begin(), string.end() });
|
||||
|
||||
if (value.size() > MaxStringLength) {
|
||||
value.resize(MaxStringLength);
|
||||
value += "...";
|
||||
}
|
||||
} else {
|
||||
value = "";
|
||||
copyValue = "";
|
||||
}
|
||||
|
||||
return [value, copyValue] { ImGuiExt::TextFormatted("u\"{0}\"", value.c_str()); return copyValue; };
|
||||
},
|
||||
[](const std::string &value, std::endian endian) -> std::vector<u8> {
|
||||
std::ignore = endian;
|
||||
|
||||
return hex::decodeByteString(value);
|
||||
}
|
||||
);
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.string32", sizeof(char32_t),
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
std::ignore = buffer;
|
||||
std::ignore = endian;
|
||||
std::ignore = style;
|
||||
|
||||
auto currSelection = ImHexApi::HexEditor::getSelection();
|
||||
|
||||
std::string value, copyValue;
|
||||
|
||||
if (currSelection.has_value()) {
|
||||
std::u32string stringBuffer(std::min<size_t>(currSelection->size * sizeof(char32_t), 0x1000), 0x00);
|
||||
ImHexApi::Provider::get()->read(currSelection->address, stringBuffer.data(), stringBuffer.size());
|
||||
|
||||
for (auto &c : stringBuffer)
|
||||
c = hex::changeEndianness(c, endian);
|
||||
|
||||
std::erase_if(buffer, [](auto c) { return c == 0x00; });
|
||||
|
||||
auto string = wolv::util::utf32ToUtf8(stringBuffer).value_or("Invalid");
|
||||
value = copyValue = hex::encodeByteString({ string.begin(), string.end() });
|
||||
|
||||
if (value.size() > MaxStringLength) {
|
||||
value.resize(MaxStringLength);
|
||||
value += "...";
|
||||
}
|
||||
} else {
|
||||
value = "";
|
||||
copyValue = "";
|
||||
}
|
||||
|
||||
return [value, copyValue] { ImGuiExt::TextFormatted("U\"{0}\"", value.c_str()); return copyValue; };
|
||||
},
|
||||
[](const std::string &value, std::endian endian) -> std::vector<u8> {
|
||||
std::ignore = endian;
|
||||
|
||||
return hex::decodeByteString(value);
|
||||
}
|
||||
);
|
||||
|
||||
#if defined(OS_WINDOWS)
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.time32", sizeof(u32), [](auto buffer, auto endian, auto style) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user