[Piglit] [PATCH 1/2] Changed piglit-summary-html to explicitly encode its output as UTF-8.
Paul Berry
stereotype441 at gmail.com
Mon Aug 8 10:52:56 PDT 2011
Previously piglit-summary-html didn't explicitly encode its output at
all--it relied on the default behavior of the Python file.write()
method (which, in Python 2.x, is to write 8-bit strings verbatim and
to encode unicode strings using ASCII). This meant that if a
non-ASCII character appeared in any of the test data,
piglit-summary-html would fail with an exception.
This patch changes piglit-summary-html to explicitly encode its output
using UTF-8. It also updates all of the HTML templates to specify
UTF-8 as the encoding, so that when results are viewed in a web
browser, non-ASCII characters will display correctly.
---
piglit-summary-html.py | 2 +-
templates/index.html | 1 +
templates/result.html | 1 +
templates/testrun.html | 1 +
4 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/piglit-summary-html.py b/piglit-summary-html.py
index 63d8b60..726319c 100755
--- a/piglit-summary-html.py
+++ b/piglit-summary-html.py
@@ -50,7 +50,7 @@ def readfile(filename):
def writefile(filename, text):
f = open(filename, "w")
- f.write(text)
+ f.write(text.encode('utf-8'))
f.close()
templatedir = os.path.join(os.path.dirname(__file__), 'templates')
diff --git a/templates/index.html b/templates/index.html
index d6bf392..ff347df 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1,5 +1,6 @@
<html>
<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Result summary </title>
<link rel="stylesheet" href="index.css"/>
</head>
diff --git a/templates/result.html b/templates/result.html
index d6167e7..f90ff3d 100644
--- a/templates/result.html
+++ b/templates/result.html
@@ -1,5 +1,6 @@
<html>
<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>%(path)s - Details</title>
<link rel="stylesheet" href="../result.css"/>
</head>
diff --git a/templates/testrun.html b/templates/testrun.html
index a04ec0d..572381f 100644
--- a/templates/testrun.html
+++ b/templates/testrun.html
@@ -1,5 +1,6 @@
<html>
<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>%(name)s - System info</title>
<link rel="stylesheet" href="../result.css"/>
</head>
--
1.7.6
More information about the Piglit
mailing list