diff --git a/lang/qt/src/threadedjobmixin.cpp b/lang/qt/src/threadedjobmixin.cpp index 3302918b..92e63849 100644 --- a/lang/qt/src/threadedjobmixin.cpp +++ b/lang/qt/src/threadedjobmixin.cpp @@ -53,53 +53,10 @@ using namespace QGpgME; using namespace GpgME; -#ifdef Q_OS_WIN -#include - -static QString fromEncoding (unsigned int src_encoding, const char *data) -{ - int n = MultiByteToWideChar(src_encoding, 0, data, -1, NULL, 0); - if (n < 0) { - return QString(); - } - - wchar_t *result = (wchar_t *) malloc ((n+1) * sizeof *result); - - n = MultiByteToWideChar(src_encoding, 0, data, -1, result, n); - if (n < 0) { - free(result); - return QString(); - } - const auto ret = QString::fromWCharArray(result, n); - free(result); - return ret; -} -#endif - static QString stringFromGpgOutput(const QByteArray &ba) { #ifdef Q_OS_WIN - /* Qt on Windows uses GetACP while GnuPG prefers - * GetConsoleOutputCP. - * - * As we are not a console application GetConsoleOutputCP - * usually returns 0. - * From experience the closest thing that let's us guess - * what GetConsoleOutputCP returns for a console application - * it appears to be the OEMCP. - */ - unsigned int cpno = GetConsoleOutputCP (); - if (!cpno) { - cpno = GetOEMCP(); - } - if (!cpno) { - cpno = GetACP(); - } - if (!cpno) { - return QString(); - } - - return fromEncoding(cpno, ba.constData()); + return QString::fromUtf8(ba); #else return QString::fromLocal8Bit(ba); #endif