Skip to content

Commit 03e53eb

Browse files
committed
Parse tooltip files as utf-8 encoded
1 parent 736a615 commit 03e53eb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

gcodeworkshop/src/gcoderdocument.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#include <QVariant> // for QVariant
5050
#include <QWidget> // for QWidget
5151
#include <Qt> // for CaseInsensitive, CaseSensitive, CaseSensitivity, WA_DeleteOnClose, Custo...
52-
#include <QtGlobal> // for QFlags, QFlags<>::enum_type, qDebug
52+
#include <QtGlobal> // for QFlags, QFlags<>::enum_type, qDebug, QT_VERSION, QT_VERSION_CHECK
5353

5454
class QMenu;
5555

@@ -639,7 +639,14 @@ void GCoderDocument::loadToolTips(QHash<QString, QString>& tips, const QString&
639639
{
640640
if (QFile::exists(fileName)) {
641641
QSettings settings(fileName, QSettings::IniFormat);
642+
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
643+
// Qt5: By default QSettings will accept Latin-1 encoded INI files,
644+
// where non-ASCII values are encoded using standard INI escape sequences.
645+
// Qt6: QSettings will assume that values in the INI file are utf-8 encoded.
646+
settings.setIniCodec("utf-8");
647+
#endif
642648
settings.beginGroup(group);
649+
643650
const QStringList& keys = settings.childKeys();
644651

645652
for (const QString& k : keys) {

0 commit comments

Comments
 (0)