qt: On Windows, use UTF-8 when logging the error text

* lang/qt/src/debug.cpp (operator<<): On Windows, interpret the error
text as UTF-8 instead of local 8-bit encoding.
--

GnuPG-bug-id: 5960
This commit is contained in:
Ingo Klöcker 2023-11-15 11:56:22 +01:00
parent 278f92b189
commit 618fea9e20
No known key found for this signature in database
GPG Key ID: F5A5D1692277A1E9

View File

@ -42,8 +42,14 @@
QDebug operator<<(QDebug debug, const GpgME::Error &err)
{
#ifdef Q_OS_WIN
// On Windows, we tell libgpg-error to return (translated) error messages as UTF-8
const auto errAsString = QString::fromUtf8(err.asString());
#else
const auto errAsString = QString::fromLocal8Bit(err.asString());
#endif
const bool oldSetting = debug.autoInsertSpaces();
debug.nospace() << err.asString() << " (code: " << err.code() << ", source: " << err.source() << ")";
debug.nospace() << errAsString << " (code: " << err.code() << ", source: " << err.source() << ")";
debug.setAutoInsertSpaces(oldSetting);
return debug.maybeSpace();
}