diff options
author | Thiago Macieira <thiago@macieira.org> | 2013-04-25 15:28:31 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-04-25 20:11:36 -0700 |
commit | 8da7a6985b057c5abfbd5ad1dbc7bdbfdcdfa0fb (patch) | |
tree | cda88bfa0bc1091f67f19b476fa28c5985684f9a /qt-gui.cpp | |
parent | 98027be1c1895013bfc3c4071c5d61d10fb70092 (diff) | |
download | subsurface-8da7a6985b057c5abfbd5ad1dbc7bdbfdcdfa0fb.tar.gz |
Ask Qt 4 to use the UTF-8 codec as the "codec for C strings"
Qt 5 does this by default, so it's not necessary there (in fact,
setCodecForCStrings was removed, so you catch any mistakes).
Now all QString methods taking a const char* or QByteArray
(constructor, append(), operator+=, operator<, etc.) will interpret
that char array as UTF-8. Conversely, the QByteArray methods taking a
QString will generate UTF-8 too. This includes the badly named
QString::fromAscii() and QString::toAscii().
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 | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/qt-gui.cpp b/qt-gui.cpp index d68071d35..d13c3c449 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -33,6 +33,7 @@ #include <QFileDialog> #include <QFileInfo> #include <QStringList> +#include <QTextCodec> #include <QTranslator> #if HAVE_OSM_GPS_MAP @@ -1874,6 +1875,15 @@ void init_qt_ui(int *argcp, char ***argvp) void init_ui(int *argcp, char ***argvp) { application = new QApplication(*argcp, *argvp); + +#if QT_VERSION < 0x050000 + // ask QString in Qt 4 to interpret all char* as UTF-8, + // like Qt 5 does. + // 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)); +#endif + GtkWidget *win; GtkWidget *nb_page; GtkWidget *dive_list; |