Skip to content

Commit

Permalink
Fixed conversion to std::wstring
Browse files Browse the repository at this point in the history
Fixes lxqt/qterminal#1143 and related issues.
  • Loading branch information
tsujan committed Jun 25, 2024
1 parent a15971a commit b8a3880
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/Emulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<unicodeText.length();i++)
Expand Down
4 changes: 2 additions & 2 deletions lib/Emulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
//#include <QPointer>
#include <QTextStream>
#include <QTimer>
#include <QStringEncoder>
#include <QStringDecoder>

#include "qtermwidget_export.h"
#include "KeyboardTranslator.h"
Expand Down Expand Up @@ -494,7 +494,7 @@ private slots:
bool _bracketedPasteMode;
QTimer _bulkTimer1{this};
QTimer _bulkTimer2{this};
QStringEncoder _fromUtf8;
QStringDecoder _toUtf16;
};

}
Expand Down

0 comments on commit b8a3880

Please sign in to comment.