From 568118af8b48b56fe567b8b8c19ff229f5a87e9e Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Tue, 5 Mar 2024 09:41:55 +0100 Subject: [PATCH] Terminal: Fix copying Japanese text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously if you tried to copy text such as "惣流・アスカ・ラングレー" an invalid char would be added after each character. This patch fixes the code so that "-1" cells are ignored. They are created because the previous cell had a width of 2. Change-Id: Iff8e60d3a4080068e188b08ded13a8c78df952f2 Reviewed-by: Cristian Adam --- src/libs/solutions/terminal/terminalsurface.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/solutions/terminal/terminalsurface.cpp b/src/libs/solutions/terminal/terminalsurface.cpp index e51c09d8944..00f26ce188f 100644 --- a/src/libs/solutions/terminal/terminalsurface.cpp +++ b/src/libs/solutions/terminal/terminalsurface.cpp @@ -456,6 +456,9 @@ std::u32string::value_type TerminalSurface::fetchCharAt(int x, int y) const if (cell->width == 0) return 0; + if (cell->chars[0] == 0xffffffff) + return 0; + QString s = QString::fromUcs4(cell->chars, 6).normalized(QString::NormalizationForm_C); const QList ucs4 = s.toUcs4(); return std::u32string(ucs4.begin(), ucs4.end()).front();