From f78620efd72eea227f069983c93c8a9e7159c3b4 Mon Sep 17 00:00:00 2001 From: Ray Chason Date: Sun, 4 Jun 2023 17:19:45 -0400 Subject: [PATCH] Qt: Convert to UTF-16 --- win/Qt/qt_map.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/win/Qt/qt_map.cpp b/win/Qt/qt_map.cpp index 5b05e1de0..78866cf90 100644 --- a/win/Qt/qt_map.cpp +++ b/win/Qt/qt_map.cpp @@ -211,8 +211,17 @@ void NetHackQtMapViewport::paintEvent(QPaintEvent* event) painter.setPen(Qt::green); #endif if (!DrawWalls(painter, i * gW, j * gH, gW, gH, ch)) { + ushort utf16[3]; + if (ch < 0x10000) { + utf16[0] = static_cast(ch); + utf16[1] = 0; + } else { + utf16[0] = static_cast((ch >> 10) + 0xD7C0); + utf16[1] = static_cast((ch & 0x3FF) + 0xDC00); + utf16[2] = 0; + } painter.drawText(i * gW, j * gH, gW, gH, Qt::AlignCenter, - QString(QChar(ch)).left(1)); + QString::fromUtf16(utf16)); } if ((special & MG_PET) != 0 && ::iflags.hilite_pet) { painter.drawPixmap(QPoint(i * gW, j * gH),