From b8a388047fc5338ec714f8292ce083baef70a0ba Mon Sep 17 00:00:00 2001 From: Tsu Jan Date: Tue, 25 Jun 2024 20:51:26 +0330 Subject: [PATCH] Fixed conversion to `std::wstring` Fixes https://github.com/lxqt/qterminal/issues/1143 and related issues. --- lib/Emulation.cpp | 8 ++++---- lib/Emulation.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Emulation.cpp b/lib/Emulation.cpp index c88ac12a..966797f1 100644 --- a/lib/Emulation.cpp +++ b/lib/Emulation.cpp @@ -52,7 +52,7 @@ Emulation::Emulation() : _keyTranslator(nullptr), _usesMouse(false), _bracketedPasteMode(false), - _fromUtf8(QStringEncoder::Utf16) + _toUtf16(QStringConverter::Utf8) { // create screens with a default size _screen[0] = new Screen(40,80); @@ -224,9 +224,9 @@ void Emulation::receiveData(const char* text, int length) * U+10FFFF * https://unicodebook.readthedocs.io/unicode_encodings.html#surrogates */ - QString str = QString::fromUtf8(text, length); - auto encoded = _fromUtf8(str); - std::wstring unicodeText = encoded.data.toStdWString(); + QByteArray ba(text, length); + QString str = _toUtf16(ba); + std::wstring unicodeText = str.toStdWString(); //send characters to terminal emulator for (size_t i=0;i #include #include -#include +#include #include "qtermwidget_export.h" #include "KeyboardTranslator.h" @@ -494,7 +494,7 @@ private slots: bool _bracketedPasteMode; QTimer _bulkTimer1{this}; QTimer _bulkTimer2{this}; - QStringEncoder _fromUtf8; + QStringDecoder _toUtf16; }; }