1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00

Merge branch 'ensure_utf8_encoding' into 'master'

Move ensureUtf8Encoding to named namespace

See merge request OpenMW/openmw!2632
This commit is contained in:
Alexei Kotov 2023-01-20 05:17:44 +00:00
commit f0e58d1c59
4 changed files with 15 additions and 13 deletions

View File

@ -308,7 +308,7 @@ bool Launcher::MainDialog::setupLauncherSettings()
return false;
}
QTextStream stream(&file);
ensureUtf8Encoding(stream);
Misc::ensureUtf8Encoding(stream);
mLauncherSettings.readFile(stream);
}
@ -344,7 +344,7 @@ bool Launcher::MainDialog::setupGameSettings()
return {};
}
QTextStream stream(&file);
ensureUtf8Encoding(stream);
Misc::ensureUtf8Encoding(stream);
(mGameSettings.*reader)(stream, ignoreContent);
file.close();
@ -544,7 +544,7 @@ bool Launcher::MainDialog::writeSettings()
QTextStream stream(&file);
stream.setDevice(&file);
ensureUtf8Encoding(stream);
Misc::ensureUtf8Encoding(stream);
mLauncherSettings.writeFile(stream);
file.close();

View File

@ -165,7 +165,7 @@ void Wizard::MainWizard::setupGameSettings()
return;
}
QTextStream stream(&file);
ensureUtf8Encoding(stream);
Misc::ensureUtf8Encoding(stream);
mGameSettings.readUserFile(stream);
}
@ -197,7 +197,7 @@ void Wizard::MainWizard::setupGameSettings()
return;
}
QTextStream stream(&file);
ensureUtf8Encoding(stream);
Misc::ensureUtf8Encoding(stream);
mGameSettings.readFile(stream);
}
@ -233,7 +233,7 @@ void Wizard::MainWizard::setupLauncherSettings()
return;
}
QTextStream stream(&file);
ensureUtf8Encoding(stream);
Misc::ensureUtf8Encoding(stream);
mLauncherSettings.readFile(stream);
}
@ -460,7 +460,7 @@ void Wizard::MainWizard::writeSettings()
}
QTextStream stream(&file);
ensureUtf8Encoding(stream);
Misc::ensureUtf8Encoding(stream);
mGameSettings.writeFile(stream);
file.close();
@ -486,7 +486,7 @@ void Wizard::MainWizard::writeSettings()
}
stream.setDevice(&file);
ensureUtf8Encoding(stream);
Misc::ensureUtf8Encoding(stream);
mLauncherSettings.writeFile(stream);
file.close();

View File

@ -230,7 +230,7 @@ bool Config::GameSettings::isOrderedLine(const QString& line)
bool Config::GameSettings::writeFileWithComments(QFile& file)
{
QTextStream stream(&file);
ensureUtf8Encoding(stream);
Misc::ensureUtf8Encoding(stream);
// slurp
std::vector<QString> fileCopy;

View File

@ -1,14 +1,16 @@
#ifndef MISC_UTF8QTEXTSTREAM_HPP
#define MISC_UTF8QTEXTSTREAM_HPP
#ifndef OPENMW_COMPONENTS_MISC_UTF8QTEXTSTREAM_HPP
#define OPENMW_COMPONENTS_MISC_UTF8QTEXTSTREAM_HPP
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QTextCodec>
#endif
#include <QTextStream>
namespace
namespace Misc
{
void ensureUtf8Encoding(QTextStream& stream)
inline void ensureUtf8Encoding(QTextStream& stream)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
stream.setCodec(QTextCodec::codecForName("UTF-8"));