diff options
author | Thiago Macieira <thiago@macieira.org> | 2013-12-19 17:02:34 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-12-20 09:53:05 -0800 |
commit | 8eb6dfdb02cf7b9d2c92f9e6ef28ad5312415302 (patch) | |
tree | c30921972538ec90afa11eb62c664ea58efac8d0 /qt-gui.cpp | |
parent | dbdf50d03cd19b8cf62f39a2578996215f47034e (diff) | |
download | subsurface-8eb6dfdb02cf7b9d2c92f9e6ef28ad5312415302.tar.gz |
Use QFile::{encode,decode}Name for file names
And make them use UTF-8 on Windows instead of the local 8 bit encoding.
This will also get us the proper NFD encoding on OS X.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-gui.cpp')
-rw-r--r-- | qt-gui.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/qt-gui.cpp b/qt-gui.cpp index 84e79a99f..fe2068ab0 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -66,6 +66,18 @@ const char *getSetting(QSettings &s, QString name) return NULL; } +#ifdef Q_OS_WIN +static QByteArray encodeUtf8(const QString &fname) +{ + return fname.toUtf8(); +} + +static QString decodeUtf8(const QByteArray &fname) +{ + return QString::fromUtf8(fname); +} +#endif + void init_ui(int *argcp, char ***argvp) { QVariant v; @@ -82,6 +94,10 @@ void init_ui(int *argcp, char ***argvp) // 106 is "UTF-8", this is faster than lookup by name // [http://www.iana.org/assignments/character-sets/character-sets.xml] QTextCodec::setCodecForCStrings(QTextCodec::codecForMib(106)); +# ifdef Q_OS_WIN + QFile::setDecodingFunction(decodeUtf8); + QFile::setEncodingFunction(encodeUtf8); +# endif #endif QCoreApplication::setOrganizationName("Subsurface"); QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); |