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

UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' #24

Closed
annalinneajohansson opened this issue Jan 27, 2015 · 4 comments
Closed

Comments

@annalinneajohansson
Copy link

Changing the timezone to Europe/Stockholm in .togglrc gives me this error when trying to run toggl.py:

Traceback (most recent call last):
  File "toggl.py", line 1063, in <module>
    CLI().act()
  File "toggl.py", line 893, in act
    Logger.info(TimeEntryList())
  File "toggl.py", line 271, in info
    print("%s%s" % (msg, end)),
  File "toggl.py", line 752, in __str__
    s += str(entry) + "\n"
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 6: ordinal not in range(128)
@drobertadams
Copy link
Collaborator

That means your editor entered a special character that Python can't handle. Make sure that you are using a plain text editor that isn't inserting unicode characters. I changed my timezone to "Europe/Stockholm" and it worked just fine.

@annalinneajohansson
Copy link
Author

Thanks for the instructions, I'll make sure to try that then.

@pbihler
Copy link

pbihler commented Aug 26, 2015

The error has nothing to do with the timezone, but with user's native language... And for a scandinavian, it is not unusual to have a "ô" in their project names or entries (http://www.fileformat.info/info/unicode/char/00F4/index.htm).

The problem seems to be that the python script can't handle non-english (= non 7bit ascii) characters at all currently...

@pbihler
Copy link

pbihler commented Aug 26, 2015

Quickfix: set line 720 to return s.encode('ascii','replace') - Replaces all unicode characters with a ?.
Not nice, so no pull request for this. But at least, it won't break anymore.

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

No branches or pull requests

3 participants