Skip to content

Commit

Permalink
Use UTF-8 encoding instead of Latin-1
Browse files Browse the repository at this point in the history
  • Loading branch information
scx committed Jan 13, 2019
1 parent 17a588f commit 2e9e258
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/Checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <QLocale>
#include <QMenu>
#include <QTranslator>
#include <QtDebug>

static void dict_describe_cb(const char* const lang_tag,
const char* const /*provider_name*/,
Expand Down Expand Up @@ -107,7 +108,7 @@ bool Checker::setLanguageInternal(const QString &lang)
if(m_lang.isEmpty()){
m_lang = QLocale::system().name();
if(m_lang.toLower() == "c" || m_lang.isEmpty()){
qWarning("Cannot use system locale %s", m_lang.toLatin1().data());
qWarning() << "Cannot use system locale " << m_lang;
m_lang = QString::null;
return false;
}
Expand All @@ -117,7 +118,7 @@ bool Checker::setLanguageInternal(const QString &lang)
try {
m_speller = get_enchant_broker()->request_dict(m_lang.toStdString());
} catch(enchant::Exception& e) {
qWarning("Failed to load dictionary: %s", e.what());
qWarning() << "Failed to load dictionary: " << e.what();
m_lang = QString::null;
return false;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Codetable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <QDir>
#include <QFile>
#include <QXmlStreamReader>
#include <QtDebug>
#include <libintl.h>

#define ISO_639_DOMAIN "iso_639"
Expand Down Expand Up @@ -77,7 +78,7 @@ void Codetable::parseIso639Elements(const QXmlStreamReader &xml, QMap<QString, Q
QString name = xml.attributes().value("name").toString();
QString code = xml.attributes().value("iso_639_1_code").toString();
if(!name.isEmpty() && !code.isEmpty()){
name = QString::fromUtf8(dgettext(ISO_639_DOMAIN, name.toLatin1().data()));
name = QString::fromUtf8(dgettext(ISO_639_DOMAIN, name.toUtf8().constData()));
table.insert(code, name);
}
}
Expand All @@ -89,7 +90,7 @@ void Codetable::parseIso3166Elements(const QXmlStreamReader &xml, QMap<QString,
QString name = xml.attributes().value("name").toString();
QString code = xml.attributes().value("alpha_2_code").toString();
if(!name.isEmpty() && !code.isEmpty()){
name = QString::fromUtf8(dgettext(ISO_3166_DOMAIN, name.toLatin1().data()));;
name = QString::fromUtf8(dgettext(ISO_3166_DOMAIN, name.toUtf8().constData()));
table.insert(code, name);
}
}
Expand All @@ -100,7 +101,7 @@ void Codetable::parse(const QDir& dataDir, const QString& basename, const parser
QString filename = QDir(QDir(dataDir.filePath("xml")).filePath("iso-codes")).absoluteFilePath(basename);
QFile file(filename);
if(!file.open(QIODevice::ReadOnly)){
qWarning("Failed to open %s for reading", file.fileName().toLatin1().data());
qWarning() << "Failed to open " << file.fileName() << " for reading";
return;
}

Expand Down

0 comments on commit 2e9e258

Please sign in to comment.