fix: UTF-16BE search being broken
This commit is contained in:
parent
88e767aaaf
commit
cffd55bdda
@ -269,11 +269,11 @@ namespace hex::plugin::builtin {
|
||||
if (settings.type == UTF16LE) {
|
||||
// Check if second byte of UTF-16 encoded string is 0x00
|
||||
if (countedCharacters % 2 == 1)
|
||||
validChar = byte == 0x00;
|
||||
validChar = byte == 0x00;
|
||||
} else if (settings.type == UTF16BE) {
|
||||
// Check if first byte of UTF-16 encoded string is 0x00
|
||||
if (countedCharacters % 2 == 0)
|
||||
validChar = byte == 0x00;
|
||||
validChar = byte == 0x00;
|
||||
}
|
||||
|
||||
task.update(progress);
|
||||
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user