hfaran / slack-export-viewer

A Slack Export archive viewer that allows you to easily view and share your Slack team's export
https://pypi.python.org/pypi/slack-export-viewer
MIT License
939 stars 194 forks source link

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe3' in position 2: ordinal not in range(128)` #81

Closed georgebrindeiro closed 4 years ago

georgebrindeiro commented 5 years ago

Hi! Thanks for creating this great tool!

I am currently able to load my Slack Workspace Export, however some channels lead to a 500 Internal Server Error. Investigating the messages output in the terminal, I frequently see messages like:

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

What could that be?

Cheers, George

uavpal commented 5 years ago

same here: UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 7: ordinal not in range(128)

mine seems related to an URL: result = "<a href=\"{url}\">{title}".format(url=url, title=title)

probably similar to https://github.com/hfaran/slack-export-viewer/commit/ac4eafbd51d54c7f7379500441e38cd7f328c1bb and it's just a missing encoding="utf8" somewhere.

Rgds SoftIce

uavpal commented 5 years ago

I can get around it by adding

import sys
reload(sys)
sys.setdefaultencoding('utf8')

starting from line 7 in formatter.py. Probably only required for Python 2.7.

nylen commented 5 years ago

same error here:

  File "~/.local/venvs/slack-export-viewer/lib/python2.7/site-packages/slackviewer/formatter.py", line 101, in _sub_annotated_mention
    return mention_format.format(annotation)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 1: ordinal not in range(128)