fix: UTF-16BE search being broken

This commit is contained in:
WerWolv 2023-03-31 22:20:00 +02:00
parent 88e767aaaf
commit cffd55bdda
1 changed files with 3 additions and 6 deletions

View File

@ -520,9 +520,6 @@ namespace hex::plugin::builtin {
std::vector<u8> bytes(std::min<size_t>(occurrence.region.getSize(), 128));
provider->read(occurrence.region.getStartAddress(), bytes.data(), bytes.size());
if (occurrence.endian != std::endian::native)
std::reverse(bytes.begin(), bytes.end());
std::string result;
switch (this->m_decodeSettings.mode) {
using enum SearchSettings::Mode;
@ -537,7 +534,7 @@ namespace hex::plugin::builtin {
result = hex::encodeByteString(bytes);
break;
case UTF16:
for (size_t i = 0; i < bytes.size(); i += 2)
for (size_t i = occurrence.endian == std::endian::little ? 0 : 1; i < bytes.size(); i += 2)
result += hex::encodeByteString({ bytes[i] });
break;
case Unsigned: