From e588b3c3a1052dfc063c9c058d361347329e7899 Mon Sep 17 00:00:00 2001 From: John Fultz Date: Sat, 15 Jul 2023 21:24:54 -0500 Subject: Make UTF8-encoding of QTextStream work in Qt5 and 6. QTextStream::setCodec() is no longer a thing in Qt6. Most of our call are to set the codec to UTF-8, which happens to be the default encoding in Qt6. So make a macro so this can compile in both Qt5 and Qt6. --- quacker/quacker.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'quacker/quacker.cpp') diff --git a/quacker/quacker.cpp b/quacker/quacker.cpp index e7cc401..a244586 100644 --- a/quacker/quacker.cpp +++ b/quacker/quacker.cpp @@ -1335,7 +1335,7 @@ void TopLevel::reportAs(Quackle::ComputerPlayer *player) Quackle::ComputerPlayer *clone = player->clone(); QTextStream stream(&file); - stream.setCodec(QTextCodec::codecForName("UTF-8")); + SET_QTEXTSTREAM_TO_UTF8(stream); QuackleIO::StreamingReporter::reportGame(*m_game, clone, stream); delete clone; } @@ -2100,7 +2100,7 @@ void TopLevel::writeAsciiToFile(const QString &text, const QString &filename) } QTextStream stream(&file); - stream.setCodec(QTextCodec::codecForName("UTF-8")); + SET_QTEXTSTREAM_TO_UTF8(stream); stream << text << "\n"; file.close(); @@ -2126,7 +2126,7 @@ void TopLevel::print() } QTextStream stream(&file); - stream.setCodec(QTextCodec::codecForName("UTF-8")); + SET_QTEXTSTREAM_TO_UTF8(stream); //stream << printer.html() << "\n"; file.close(); @@ -2160,7 +2160,7 @@ void TopLevel::about() if (file) { QTextStream strm(file); - strm.setCodec("UTF-8"); + SET_QTEXTSTREAM_TO_UTF8(strm); QString line = strm.readLine(); while (!line.isNull()) { -- cgit v1.2.3