From e98604fa02e101ab8b6c38503d53c72709879a54 Mon Sep 17 00:00:00 2001 From: tiresiasfromthebai Date: Thu, 23 Jul 2026 21:24:26 +0200 Subject: [PATCH] Decode console output as UTF-8 instead of Latin-1 --- src/SeerConsoleWidget.cpp | 6 +++++- src/SeerConsoleWidget.h | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/SeerConsoleWidget.cpp b/src/SeerConsoleWidget.cpp index dadaca6..eca2829 100644 --- a/src/SeerConsoleWidget.cpp +++ b/src/SeerConsoleWidget.cpp @@ -89,7 +89,11 @@ void SeerConsoleWidget::handleText (const char* buffer, int count) { } // Write text to Ansi widget. - QString str = QString::fromLatin1(buffer, count); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QString str = _utf8Decoder.decode(QByteArrayView(buffer, count)); +#else + QString str = QString::fromUtf8(buffer, count); +#endif textEdit->insertAnsiText(str); textEdit->ensureCursorVisible(); diff --git a/src/SeerConsoleWidget.h b/src/SeerConsoleWidget.h index 8a156d4..ee02b43 100644 --- a/src/SeerConsoleWidget.h +++ b/src/SeerConsoleWidget.h @@ -10,6 +10,9 @@ #include #include #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include +#endif #include "ui_SeerConsoleWidget.h" class SeerConsoleWidget : public QWidget, protected Ui::SeerConsoleWidgetForm { @@ -73,5 +76,8 @@ class SeerConsoleWidget : public QWidget, protected Ui::SeerConsoleWidgetForm { QSocketNotifier* _ttyListener; bool _enableStdout; bool _enableWrap; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QStringDecoder _utf8Decoder{QStringConverter::Utf8}; // Keeps state across reads so multi-byte sequences split by the 1024-byte buffer decode correctly. +#endif };