From f5a4fc13000b43c07d62a3aa4627e127e760f980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Mon, 4 Dec 2023 23:48:58 +0800 Subject: [PATCH] fix log bug Chinese garbled character --- example/src/helper/Log.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/example/src/helper/Log.cpp b/example/src/helper/Log.cpp index cd1125a1..df25b97c 100644 --- a/example/src/helper/Log.cpp +++ b/example/src/helper/Log.cpp @@ -25,9 +25,9 @@ static inline void myMessageHandler(const QtMsgType type, const QMessageLogConte } const QString finalMessage = qFormatLogMessage(type, context, message).trimmed(); if ((type == QtInfoMsg) || (type == QtDebugMsg)) { - std::cout << qUtf8Printable(finalMessage) << std::endl; + std::cout << qPrintable(finalMessage) << std::endl; } else { - std::cerr << qUtf8Printable(finalMessage) << std::endl; + std::cerr << qPrintable(finalMessage) << std::endl; } if (g_logError) { return; @@ -36,7 +36,7 @@ static inline void myMessageHandler(const QtMsgType type, const QMessageLogConte g_logFile = std::make_unique(); g_logFile->setFileName(QString("debug-%1.log").arg(g_app)); if (!g_logFile->open(QFile::WriteOnly | QFile::Text | QFile::Append)) { - std::cerr << "Can't open file to write: " << qUtf8Printable(g_logFile->errorString()) << std::endl; + std::cerr << "Can't open file to write: " << qPrintable(g_logFile->errorString()) << std::endl; g_logFile.reset(); g_logError = true; return;