mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 13:05:25 -05:00
impr: Properly display custom encoding characters that are split between lines
This commit is contained in:
@@ -26,7 +26,7 @@ namespace hex {
|
||||
|
||||
if (size > buffer.size()) continue;
|
||||
|
||||
auto key = std::vector<u8>(buffer.begin(), buffer.begin() + size);
|
||||
std::vector<u8> key(buffer.begin(), buffer.begin() + size);
|
||||
if (mapping.contains(key))
|
||||
return { mapping.at(key), size };
|
||||
}
|
||||
@@ -34,6 +34,20 @@ namespace hex {
|
||||
return { ".", 1 };
|
||||
}
|
||||
|
||||
size_t EncodingFile::getEncodingLengthFor(std::span<u8> buffer) const {
|
||||
for (auto riter = this->m_mapping.crbegin(); riter != this->m_mapping.crend(); ++riter) {
|
||||
const auto &[size, mapping] = *riter;
|
||||
|
||||
if (size > buffer.size()) continue;
|
||||
|
||||
std::vector<u8> key(buffer.begin(), buffer.begin() + size);
|
||||
if (mapping.contains(key))
|
||||
return size;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void EncodingFile::parseThingyFile(wolv::io::File &file) {
|
||||
for (const auto &line : splitString(file.readString(), "\n")) {
|
||||
|
||||
@@ -60,9 +74,11 @@ namespace hex {
|
||||
|
||||
if (!this->m_mapping.contains(fromBytes.size()))
|
||||
this->m_mapping.insert({ fromBytes.size(), {} });
|
||||
this->m_mapping[fromBytes.size()].insert({ fromBytes, to });
|
||||
|
||||
this->m_longestSequence = std::max(this->m_longestSequence, fromBytes.size());
|
||||
auto keySize = fromBytes.size();
|
||||
this->m_mapping[keySize].insert({ std::move(fromBytes), to });
|
||||
|
||||
this->m_longestSequence = std::max(this->m_longestSequence, keySize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user