1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:28:10 +00:00

HexEditor: Add UTF16 to the value inspector

This commit is contained in:
kleines Filmröllchen 2022-04-12 19:12:03 +02:00 committed by Linus Groh
parent ef113b2f91
commit 19f6ef3a0c
2 changed files with 24 additions and 1 deletions

View file

@ -9,6 +9,7 @@
#include <AK/Hex.h>
#include <AK/NonnullRefPtr.h>
#include <AK/String.h>
#include <AK/Utf16View.h>
#include <AK/Utf8View.h>
#include <AK/Vector.h>
#include <LibGUI/Model.h>
@ -28,6 +29,7 @@ public:
Double,
ASCII,
UTF8,
UTF16,
__Count
};
@ -96,6 +98,8 @@ public:
return "ASCII";
case UTF8:
return "UTF-8";
case UTF16:
return "UTF-16";
default:
return "";
}
@ -137,6 +141,12 @@ public:
return static_cast<i32>(utf8_view.byte_length());
return 0;
}
case UTF16: {
auto utf16_view = Utf16View(utf8_to_utf16(m_values.at(index.row())));
if (utf16_view.validate())
return static_cast<i32>(utf16_view.length_in_code_units() * 2);
return 0;
}
default:
return 0;
}