From 8da7a6985b057c5abfbd5ad1dbc7bdbfdcdfa0fb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 25 Apr 2013 15:28:31 -0700 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-gui.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'qt-gui.cpp') 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 #include #include +#include #include #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; -- cgit v1.2.3-70-g09d2