From 990ec6d87232d2b8cea9d1809483f86a757d1acf Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Wed, 4 Jan 2023 04:55:05 +0100 Subject: [PATCH] Ask QTextStream to decode text as UTF-8 Also allow wider Unicode encodings in case a BOM is present. Closes #1692. (cherry picked from commit 7ac42b09b77cad43e5ee4c1ef198d639edfae723) --- utility/inputfile.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utility/inputfile.cpp b/utility/inputfile.cpp index 7b8d9bbb3b..65f0bcaec3 100644 --- a/utility/inputfile.cpp +++ b/utility/inputfile.cpp @@ -233,6 +233,8 @@ struct inputfile *inf_from_stream(QIODevice *stream, inf->filename.clear(); inf->fp = stream; inf->stream = new QTextStream(stream); + inf->stream->setCodec("UTF-8"); + inf->stream->setAutoDetectUnicode(true); // Allow UTF-16 and UTF-32 inf->datafn = datafn; qCDebug(inf_category) << "opened" << inf_filename(inf) << "ok";