From 20998c0dc9532630ba549af9a8321cd736c79368 Mon Sep 17 00:00:00 2001 From: Hugo Lima Date: Mon, 8 Feb 2010 14:30:13 -0200 Subject: Assumes utf-8 encoding for conversion rules stored in external files. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed by Renato Araújo --- tests/testcodeinjection.cpp | 3 +++ typesystem.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/testcodeinjection.cpp b/tests/testcodeinjection.cpp index e3619a202..b056ead83 100644 --- a/tests/testcodeinjection.cpp +++ b/tests/testcodeinjection.cpp @@ -34,6 +34,7 @@ void TestCodeInjections::testReadFileUtf8() QString xmlCode = "\ \ \ + \ \ \ \ @@ -45,6 +46,8 @@ void TestCodeInjections::testReadFileUtf8() QString code = classA->typeEntry()->codeSnips().first().code(); QString utf8Data = QString::fromUtf8("\xC3\xA1\xC3\xA9\xC3\xAD\xC3\xB3\xC3\xBA"); QVERIFY(code.indexOf(utf8Data) != -1); + code = classA->typeEntry()->conversionRule(); + QVERIFY(code.indexOf(utf8Data) != -1); } QTEST_APPLESS_MAIN(TestCodeInjections) diff --git a/typesystem.cpp b/typesystem.cpp index 220d5af1e..89dfd4768 100644 --- a/typesystem.cpp +++ b/typesystem.cpp @@ -1045,8 +1045,8 @@ bool Handler::startElement(const QString &, const QString &n, if (m_generate != TypeEntry::GenerateForSubclass && m_generate != TypeEntry::GenerateNothing) { QFile conversionSource(sourceFile); - if (conversionSource.open(QIODevice::ReadOnly)) { - topElement.entry->setConversionRule(conversionSource.readAll()); + if (conversionSource.open(QIODevice::ReadOnly | QIODevice::Text)) { + topElement.entry->setConversionRule(QString::fromUtf8(conversionSource.readAll())); } else { ReportHandler::warning("File containing conversion code for " + topElement.entry->name() -- cgit v1.2.3