[library-web] Encode xml output as UTF8
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [library-web] Encode xml output as UTF8
- Date: Tue, 18 Feb 2014 23:53:56 +0000 (UTC)
commit d4019fa5641e3ebd2e5be830da1122af2c4c3aae
Author: William Jon McCann <william jon mccann gmail com>
Date: Tue Feb 18 16:47:53 2014 -0500
Encode xml output as UTF8
src/document.py | 4 ++--
src/overlay.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/document.py b/src/document.py
index 939e2ec..9d1f1ff 100644
--- a/src/document.py
+++ b/src/document.py
@@ -246,7 +246,7 @@ class RemoteDocument(Document):
if self.href[lang].endswith('?action=print') and (
not self.title.get(lang) or ' ' not in self.title[lang]):
# wiki document with a WikiTitle
- html = ET.fromstring(doc.toxml())
+ html = ET.fromstring(doc.toxml().encode('utf-8'))
try:
title = ET.ElementTree(html).find('.//{http://www.w3.org/1999/xhtml}h1').text
except AttributeError:
@@ -267,7 +267,7 @@ class RemoteDocument(Document):
logging.debug('executing %s' % ' '.join(cmd))
xsltproc = subprocess.Popen(cmd, stdin = subprocess.PIPE)
- xsltproc.communicate(doc.toxml())
+ xsltproc.communicate(doc.toxml().encode('utf-8'))
xsltproc.wait()
if xsltproc.returncode:
logging.warn('%s failed with error %d' % (' '.join(cmd), xsltproc.returncode))
diff --git a/src/overlay.py b/src/overlay.py
index ce82a64..0cb9778 100644
--- a/src/overlay.py
+++ b/src/overlay.py
@@ -129,7 +129,7 @@ class Overlay:
parser = html5lib.HTMLParser(tree=html5lib.getTreeBuilder("dom"))
doc = parser.parse(file(content))
del doc.childNodes[:-1]
- html = ET.fromstring(doc.toxml())
+ html = ET.fromstring(doc.toxml().encode('utf-8'))
links = ET.ElementTree(html).findall('//a')
channel = extra.find('channel').text
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]