summaryrefslogtreecommitdiff
path: root/tablib
diff options
context:
space:
mode:
authorKenneth Reitz <me@kennethreitz.org>2014-01-08 11:47:26 -0800
committerKenneth Reitz <me@kennethreitz.org>2014-01-08 11:47:26 -0800
commit45121ddd6528a02dcf8d159b304cac97b3f352ee (patch)
treed7d742ae6180bb7747b1d88355afd39e9989bfb5 /tablib
parentc74357cb20b1ac4e7496eaf6d05a5714317d4b5f (diff)
parent71603662b1d81a0fa9566cf68cb3fc5a584bdffd (diff)
downloadtablib-45121ddd6528a02dcf8d159b304cac97b3f352ee.tar.gz
Merge pull request #63 from jsdalton/fix_unicode_error_in_html_output
Fix unicode error in html output
Diffstat (limited to 'tablib')
-rw-r--r--tablib/formats/_html.py5
-rw-r--r--tablib/packages/markup.py12
2 files changed, 10 insertions, 7 deletions
diff --git a/tablib/formats/_html.py b/tablib/formats/_html.py
index 19c8081..c516e31 100644
--- a/tablib/formats/_html.py
+++ b/tablib/formats/_html.py
@@ -14,6 +14,7 @@ else:
from tablib.packages import markup
import tablib
+import codecs
BOOK_ENDINGS = 'h3'
@@ -45,7 +46,9 @@ def export_set(dataset):
page.table.close()
- stream.writelines(str(page))
+ # Allow unicode characters in output
+ wrapper = codecs.getwriter("utf8")(stream)
+ wrapper.writelines(unicode(page))
return stream.getvalue()
diff --git a/tablib/packages/markup.py b/tablib/packages/markup.py
index 234f116..0198899 100644
--- a/tablib/packages/markup.py
+++ b/tablib/packages/markup.py
@@ -67,7 +67,7 @@ class element:
def render( self, tag, single, between, kwargs ):
"""Append the actual tags to content."""
- out = "<%s" % tag
+ out = u"<%s" % tag
for key, value in kwargs.iteritems( ):
if value is not None: # when value is None that means stuff like <... checked>
key = key.strip('_') # strip this so class_ will mean class, etc.
@@ -75,16 +75,16 @@ class element:
key = 'http-equiv'
elif key == 'accept_charset':
key = 'accept-charset'
- out = "%s %s=\"%s\"" % ( out, key, escape( value ) )
+ out = u"%s %s=\"%s\"" % ( out, key, escape( value ) )
else:
- out = "%s %s" % ( out, key )
+ out = u"%s %s" % ( out, key )
if between is not None:
- out = "%s>%s</%s>" % ( out, between, tag )
+ out = u"%s>%s</%s>" % ( out, between, tag )
else:
if single:
- out = "%s />" % out
+ out = u"%s />" % out
else:
- out = "%s>" % out
+ out = u"%s>" % out
if self.parent is not None:
self.parent.content.append( out )
else: