Skip to content

Commit 8d2f7bb

Browse files
committed
[processing] correctly write html output in utf-8
1 parent acf7493 commit 8d2f7bb

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

python/plugins/processing/algs/qgis/BasicStatisticsNumbers.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
__revision__ = '$Format:%H$'
2727

2828
import math
29+
import codecs
2930

3031
from qgis.core import QgsStatisticalSummary
3132
from processing.core.GeoAlgorithm import GeoAlgorithm
@@ -178,7 +179,11 @@ def processAlgorithm(self, progress):
178179
self.setOutputValue(self.IQR, iqr)
179180

180181
def createHTML(self, outputFile, algData):
181-
f = open(outputFile, 'w')
182+
f = codecs.open(outputFile, 'w', encoding='utf-8')
183+
f.write('<html><head>')
184+
f.write('<meta http-equiv="Content-Type" content="text/html; \
185+
charset=utf-8" /></head><body>')
182186
for s in algData:
183187
f.write('<p>' + unicode(s) + '</p>')
188+
f.write('</body></html>')
184189
f.close()

python/plugins/processing/algs/qgis/NearestNeighbourAnalysis.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
__revision__ = '$Format:%H$'
2727

2828
import math
29+
import codecs
2930
from qgis.core import QgsFeatureRequest, QgsFeature, QgsDistanceArea
3031
from processing.core.GeoAlgorithm import GeoAlgorithm
3132
from processing.core.parameters import ParameterVector
@@ -115,7 +116,11 @@ def processAlgorithm(self, progress):
115116
self.setOutputValue(self.Z_SCORE, float(data[4].split(': ')[1]))
116117

117118
def createHTML(self, outputFile, algData):
118-
f = open(outputFile, 'w')
119+
f = codecs.open(outputFile, 'w', encoding='utf-8')
120+
f.write('<html><head>')
121+
f.write('<meta http-equiv="Content-Type" content="text/html; \
122+
charset=utf-8" /></head><body>')
119123
for s in algData:
120124
f.write('<p>' + unicode(s) + '</p>')
125+
f.write('</body></html>')
121126
f.close()

python/plugins/processing/algs/qgis/RasterLayerStatistics.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
__revision__ = '$Format:%H$'
2727

2828
import math
29+
import codecs
2930

3031
from processing.core.GeoAlgorithm import GeoAlgorithm
3132
from processing.core.parameters import ParameterRaster
@@ -114,7 +115,11 @@ def defineCharacteristics(self):
114115
self.addOutput(OutputNumber(self.STD_DEV, self.tr('Standard deviation')))
115116

116117
def createHTML(self, outputFile, algData):
117-
f = open(outputFile, 'w')
118+
f = codecs.open(outputFile, 'w', encoding='utf-8')
119+
f.write('<html><head>')
120+
f.write('<meta http-equiv="Content-Type" content="text/html; \
121+
charset=utf-8" /></head><body>')
118122
for s in algData:
119123
f.write('<p>' + unicode(s) + '</p>')
124+
f.write('</body></html>')
120125
f.close()

0 commit comments

Comments
 (0)