From 3b3e62cd76dbd0c0a8da7ba812f546f01b3c0e73 Mon Sep 17 00:00:00 2001 From: nowrep Date: Wed, 20 Feb 2013 19:50:59 +0100 Subject: [PATCH] [code] Explicitly set UTF-8 codec when using QTextStream. Fixes encoding issues on Windows. Closes #769 --- CHANGELOG | 1 + src/lib/adblock/adblockmanager.cpp | 3 ++- src/lib/adblock/adblocksubscription.cpp | 2 ++ src/lib/network/schemehandlers/ftpschemehandler.cpp | 1 + src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.cpp | 2 ++ src/lib/plugins/qtwebkit/spellcheck/speller.cpp | 2 ++ 6 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index d733c0273..6da081ab1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -32,6 +32,7 @@ Version 1.4.0 * fixed possible crash in saving page screen of a really long page * fixed showing window in fullscreen with XFCE * X11: fixed Ctrl+Q shortcut for DEs other than KDE and Gnome + * windows: fixed downloading utf-8 encoded adblock subscriptions * windows: improved installer allows registering as default web browser * windows: check and set as default browser from preferences * mac: fixed not working global menu after closing browser window diff --git a/src/lib/adblock/adblockmanager.cpp b/src/lib/adblock/adblockmanager.cpp index 4a88c8065..92b8ed157 100644 --- a/src/lib/adblock/adblockmanager.cpp +++ b/src/lib/adblock/adblockmanager.cpp @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2012 David Rosca +* Copyright (C) 2010-2013 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -213,6 +213,7 @@ void AdBlockManager::load() } QTextStream textStream(&file); + textStream.setCodec("UTF-8"); QString title = textStream.readLine(1024).remove(QLatin1String("Title: ")); QUrl url = QUrl(textStream.readLine(1024).remove(QLatin1String("Url: "))); diff --git a/src/lib/adblock/adblocksubscription.cpp b/src/lib/adblock/adblocksubscription.cpp index a6f5a49ff..ae1261e9a 100644 --- a/src/lib/adblock/adblocksubscription.cpp +++ b/src/lib/adblock/adblocksubscription.cpp @@ -103,6 +103,7 @@ void AdBlockSubscription::loadSubscription(const QStringList &disabledRules) } QTextStream textStream(&file); + textStream.setCodec("UTF-8"); // Header is on 3rd line textStream.readLine(1024); textStream.readLine(1024); @@ -422,6 +423,7 @@ void AdBlockCustomList::saveSubscription() } QTextStream textStream(&file); + textStream.setCodec("UTF-8"); textStream << "Title: " << title() << endl; textStream << "Url: " << url().toString() << endl; textStream << "[Adblock Plus 1.1.1]" << endl; diff --git a/src/lib/network/schemehandlers/ftpschemehandler.cpp b/src/lib/network/schemehandlers/ftpschemehandler.cpp index 528fa8212..15e7834db 100644 --- a/src/lib/network/schemehandlers/ftpschemehandler.cpp +++ b/src/lib/network/schemehandlers/ftpschemehandler.cpp @@ -166,6 +166,7 @@ void FtpSchemeReply::processData() { open(ReadOnly | Unbuffered); QTextStream stream(&m_buffer); + stream.setCodec("UTF-8"); stream << m_ftp->readAll(); diff --git a/src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.cpp b/src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.cpp index 1a5dc81f5..2e8e8ace0 100644 --- a/src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.cpp +++ b/src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.cpp @@ -43,6 +43,7 @@ SpellCheckDialog::SpellCheckDialog(QWidget* parent) else { QString word; QTextStream stream(&file); + stream.setCodec("UTF-8"); while (!stream.atEnd()) { stream >> word; @@ -120,6 +121,7 @@ void SpellCheckDialog::saveSettings() } QTextStream stream(&file); + stream.setCodec("UTF-8"); int count = ui->userDictList->count(); for (int i = 0; i < count; ++i) { diff --git a/src/lib/plugins/qtwebkit/spellcheck/speller.cpp b/src/lib/plugins/qtwebkit/spellcheck/speller.cpp index 2c63e772a..7dda8d0c0 100644 --- a/src/lib/plugins/qtwebkit/spellcheck/speller.cpp +++ b/src/lib/plugins/qtwebkit/spellcheck/speller.cpp @@ -99,6 +99,7 @@ void Speller::initialize() else { QString word; QTextStream stream(&m_userDictionary); + stream.setCodec("UTF-8"); while (!stream.atEnd()) { stream >> word; putWord(word); @@ -204,6 +205,7 @@ void Speller::addToDictionary() } QTextStream stream(&m_userDictionary); + stream.setCodec("UTF-8"); stream << word << endl; m_userDictionary.close(); }