mirror of
https://github.com/epasveer/seer.git
synced 2026-08-29 08:34:42 +08:00
Merge pull request #490 from tiresiasfromthebai/fix-console-utf8
Decode console output as UTF-8 instead of Latin-1
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
#include <QtGui/QShowEvent>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QSocketNotifier>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QtCore/QStringConverter>
|
||||
#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
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user