aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Klöcker <[email protected]>2023-11-15 10:56:22 +0000
committerIngo Klöcker <[email protected]>2023-11-15 10:57:18 +0000
commit618fea9e2006475bf849da1c1837e0d788f30a80 (patch)
tree4ce9bd7d8d39d9578a93a36a904c48be55f4cfe3
parentqt: Remove left-over partial files more persistently (diff)
downloadgpgme-618fea9e2006475bf849da1c1837e0d788f30a80.tar.gz
gpgme-618fea9e2006475bf849da1c1837e0d788f30a80.zip
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
-rw-r--r--lang/qt/src/debug.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lang/qt/src/debug.cpp b/lang/qt/src/debug.cpp
index b563ac0c..2f6d200b 100644
--- a/lang/qt/src/debug.cpp
+++ b/lang/qt/src/debug.cpp
@@ -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();
}