QSysInfo(linux): Use UTF-8 format read file

...Of the "readEtcFile" function

According to
https://www.freedesktop.org/software/systemd/man/os-release.html
it says "All strings should be in UTF-8 format".

Change-Id: Icd2d75eca2ac7273c7f587a1e3c0430cc6d2c31d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
JiDe Zhang 2018-08-16 17:18:22 +08:00
parent f0066cae8f
commit e31febb024

View File

@ -2142,11 +2142,20 @@ struct QUnixOSVersion
static QString unquote(const char *begin, const char *end)
{
// man os-release says:
// Variable assignment values must be enclosed in double
// or single quotes if they include spaces, semicolons or
// other special characters outside of AZ, az, 09. Shell
// special characters ("$", quotes, backslash, backtick)
// must be escaped with backslashes, following shell style.
// All strings should be in UTF-8 format, and non-printable
// characters should not be used. It is not supported to
// concatenate multiple individually quoted strings.
if (*begin == '"') {
Q_ASSERT(end[-1] == '"');
return QString::fromLatin1(begin + 1, end - begin - 2);
return QString::fromUtf8(begin + 1, end - begin - 2);
}
return QString::fromLatin1(begin, end - begin);
return QString::fromUtf8(begin, end - begin);
}
static QByteArray getEtcFileContent(const char *filename)
{