Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode data breaks HTML export #62

Closed
jsdalton opened this issue May 10, 2012 · 2 comments
Closed

Unicode data breaks HTML export #62

jsdalton opened this issue May 10, 2012 · 2 comments
Labels

Comments

@jsdalton
Copy link

This is nearly identical to the issue reported in #5 -- basically if there are unicode characters in data they'll break in the HTML output.

Here's the same example from that error report:

Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from tablib import Dataset
>>> data = [u'\xfc', u'\xfd']
>>> dataset = Dataset()
>>> dataset.append(data)
>>> dataset.dict
[[u'\xfc', u'\xfd']]
>>> dataset.csv
'\xc3\xbc,\xc3\xbd\r\n'
>>> dataset.html
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "*****/lib/python2.7/site-packages/tablib/formats/_html.py", line 44, in export_set
    stream.writelines(str(page))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 16: ordinal not in range(128)

Looks like this is because of cStringIO -- see this stackoverflow question: http://stackoverflow.com/questions/1817695/python-how-to-get-stringio-writelines-to-accept-unicode-string

@runekaagaard
Copy link

Unicode still breaks html output. This simple usecase illustrates it:

# coding=utf-8

import tablib

data = tablib.Dataset()
data.append(u"å")
data.html

Gives you

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in position 16: ordinal not in range(128)

@kennethreitz
Copy link
Contributor

This project is in a bit of a crisis state — it's really useful, and I use regularly. However, I wrote it several years ago and haven't touched it since. In order to get the project into a stable state I'm closing all issues and pull requests to get a "fresh slate"

Don't take this as aggressive — it's just necessary for the project to make any progress any time soon (it's pretty clear the project is effectively unmaintained at the moment). Great things to come! Please watch the GitHub logs and feel free to re-open this discussion soon. I just need to really it into a good state first.

✨ ❤️ ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants