Commit 13bc5bcd authored by Frederik Gladhorn's avatar Frederik Gladhorn

EDID parsing: replace non-printable characters with '-'

Summary:
Simplify first to not have zero terminators suddenly replaced by '-'.
This makes some screen names a lot more readable since the encoding
seems always problematic. According to the standard it should be ipm
437, but even with that code page, many EDIDs seem to produce garbage.
Local8Bit also doesn't make much sense, so use Latin1 as a good
compromise and replace everything that's not in range.

Reviewers: #plasma, mart

Reviewed By: #plasma, mart

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D14549
parent 0f32d126
......@@ -121,7 +121,7 @@ void TestEdid::testEdidParser_data()
<< QStringLiteral("SHP")
<< QStringList({QStringLiteral("SHP"), QStringLiteral("Sharp Corporation")})
<< QStringLiteral("")
<< QStringLiteral("RXN49\uFFFDLQ133Z1")
<< QStringLiteral("RXN49-LQ133Z1")
<< QStringLiteral("3627c3534e4c82871967b57237bf5b83")
<< 29U << 17U << 2.2
<< QQuaternion(1, QVector3D(0.639648, 0.328125, 0))
......
......@@ -407,8 +407,12 @@ QString Edid::Private::edidParseString(const quint8 *data) const
{
/* this is always 13 bytes, but we can't guarantee it's null
* terminated or not junk. */
auto text = QString::fromLocal8Bit(reinterpret_cast<const char*>(data), 13);
auto text = QString::fromLatin1(reinterpret_cast<const char*>(data), 13).simplified();
// Remove newlines, extra spaces and stuff
return text.simplified();
for (int i = 0; i < text.length(); ++i) {
if (!text.at(i).isPrint()) {
text[i] = '-';
}
}
return text;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment