changeset 70:3438f5cce8cc

Force text codec for html to use UTF-8
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 29 Sep 2016 14:41:48 +0200
parents dab9c19252bd
children 7e195eacb0da
files src/converter.cpp
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/converter.cpp	Thu Sep 29 14:40:06 2016 +0200
+++ b/src/converter.cpp	Thu Sep 29 14:41:48 2016 +0200
@@ -161,6 +161,7 @@
     QTextDocument doc;
     QString htmlString;
     QTextStream html (&htmlString);
+    html.setCodec("UTF-8");
 
     ConditionalFormatting bars;
 
@@ -180,8 +181,8 @@
     xlsx.setColumnHidden(26, true);
 
     int row = 1;
-    html << "<html><meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">"
-            "<body><table border=\"0\" width:\"100%\">";
+    html << "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\"/>"
+            "</head><body><table border=\"0\" width:\"100%\">";
     html << QStringLiteral("<tr><th width=\"%1%\"></th>").arg(HTML_COL1_PERCENT);
     html << QStringLiteral("<th width=\"%1%\"></th>").arg(HTML_COL2_PERCENT);
     html << QStringLiteral("<th width=\"%1%\"></th>").arg(HTML_COL3_PERCENT);
@@ -286,7 +287,7 @@
                 cursor = choiceMatch.capturedEnd();
                 /* Alternative answer that is just a list of strings */
                 unescapeString(choice);
-                qDebug() << "Caputured unfilled choice: " << choice;
+                qDebug() << "Captured unfilled choice: " << choice;
                 html << mChoiceTextStyle.arg(choice.toHtmlEscaped());
                 makeBar(html, 0, doc);
                 xlsx.write(row, 2, QVariant());
@@ -400,6 +401,7 @@
         const QString fName = output->fileName().toLower();
         if (fName.endsWith(".html")) {
             QTextStream outstream(output);
+            outstream.setCodec("UTF-8");
             outstream << htmlString;
             output->close();
         } else if (fName.endsWith(".pdf")) {
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)