1
0
Fork 0

GUI: handle \0 characters in HexLineEdit (shows as space but doesn't replace your bytes with 0x2E)

This commit is contained in:
mrexodia 2016-06-06 12:21:56 +02:00
parent a0307a0974
commit 9d2335cbbb
No known key found for this signature in database
GPG Key ID: D72F9A4FAA0073B4
1 changed files with 4 additions and 9 deletions

View File

@ -48,10 +48,10 @@ void HexLineEdit::keyPressEvent(QKeyEvent* event)
switch(mEncoding)
{
case Encoding::Ascii:
keyText = event->text().toLatin1();
keyText = event->text().toLatin1();
break;
case Encoding::Unicode:
keyText = event->text();
keyText = event->text();
break;
}
@ -74,10 +74,8 @@ void HexLineEdit::setData(const QByteArray & data)
for(int i = 0; i < data.size(); i++)
{
QChar ch(data.constData()[i]);
if(ch.isPrint())
if(ch >= 0 && ch <= 255)
text += ch.toLatin1();
else
text += '.';
}
break;
@ -85,10 +83,7 @@ void HexLineEdit::setData(const QByteArray & data)
for(int i = 0, j = 0; i < data.size(); i += sizeof(wchar_t), j++)
{
QChar wch(((wchar_t*)data.constData())[j]);
if(wch.isPrint())
text += wch;
else
text += '.';
text += wch;
}
break;
}