mirror of https://github.com/WerWolv/ImHex.git
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) {
|
if (settings.type == UTF16LE) {
|
||||||
// Check if second byte of UTF-16 encoded string is 0x00
|
// Check if second byte of UTF-16 encoded string is 0x00
|
||||||
if (countedCharacters % 2 == 1)
|
if (countedCharacters % 2 == 1)
|
||||||
validChar = byte == 0x00;
|
validChar = byte == 0x00;
|
||||||
} else if (settings.type == UTF16BE) {
|
} else if (settings.type == UTF16BE) {
|
||||||
// Check if first byte of UTF-16 encoded string is 0x00
|
// Check if first byte of UTF-16 encoded string is 0x00
|
||||||
if (countedCharacters % 2 == 0)
|
if (countedCharacters % 2 == 0)
|
||||||
validChar = byte == 0x00;
|
validChar = byte == 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
task.update(progress);
|
task.update(progress);
|
||||||
|
@ -520,9 +520,6 @@ namespace hex::plugin::builtin {
|
||||||
std::vector<u8> bytes(std::min<size_t>(occurrence.region.getSize(), 128));
|
std::vector<u8> bytes(std::min<size_t>(occurrence.region.getSize(), 128));
|
||||||
provider->read(occurrence.region.getStartAddress(), bytes.data(), bytes.size());
|
provider->read(occurrence.region.getStartAddress(), bytes.data(), bytes.size());
|
||||||
|
|
||||||
if (occurrence.endian != std::endian::native)
|
|
||||||
std::reverse(bytes.begin(), bytes.end());
|
|
||||||
|
|
||||||
std::string result;
|
std::string result;
|
||||||
switch (this->m_decodeSettings.mode) {
|
switch (this->m_decodeSettings.mode) {
|
||||||
using enum SearchSettings::Mode;
|
using enum SearchSettings::Mode;
|
||||||
|
@ -537,7 +534,7 @@ namespace hex::plugin::builtin {
|
||||||
result = hex::encodeByteString(bytes);
|
result = hex::encodeByteString(bytes);
|
||||||
break;
|
break;
|
||||||
case UTF16:
|
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] });
|
result += hex::encodeByteString({ bytes[i] });
|
||||||
break;
|
break;
|
||||||
case Unsigned:
|
case Unsigned:
|
||||||
|
|
Loading…
Reference in New Issue