tumblr / pytumblr

A Python Tumblr API v2 Client
Apache License 2.0
723 stars 196 forks source link

How to solve "ascii" unicode errors? #43

Closed BuddhaSource closed 10 years ago

BuddhaSource commented 10 years ago

While most of the posts that user copy paste runs fine however I can see lot of ascii errors at

resp = self.client.create_text(target_blog.id, title=post.title, body=post.content, tags=tags, date=post.date)

The error is in general with title or body.

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

While I do try to " decode('utf-8', 'ignore') " but still in vain. I get errors only from this library.

Any thoughts?

codingjester commented 10 years ago

Hey @BuddhaSource What are you actually trying to post and what version of python are you using?

BuddhaSource commented 10 years ago

Hi @codingjester Sorry it was my fault. I was able to solve all the unicode errors by simply adding this on top of the py file. It just took lot of time to figure it out.

import sys;
reload(sys);
sys.setdefaultencoding("utf8")