From e7d213c5468feaaf1046c668f2a0cbcb0c7b0ed3 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Sat, 5 Jan 2013 14:48:13 +0100 Subject: [PATCH] Set text codec to UTF8 fixing the handling of special characters Set the encoding used by Qt to UTF8. This fixes the wrong appearance of special characters caused by SQLite using UTF8 and the application ISO-8859 or whatever. --- src/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 9d8a4dbd..6059e855 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ #include "MainWindow.h" #include +#include #if defined(Q_WS_MAC) #include @@ -72,6 +73,12 @@ int main( int argc, char ** argv ) QApplication a( argc, argv ); a.setOrganizationName("sqlitebrowser"); a.setApplicationName("SQLite Database Browser " + QString(APP_VERSION)); + + // Set character encoding to UTF8 + QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); + QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); + QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); + MainWindow w; #if defined(Q_WS_MAC) AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,