Linked Questions
22 questions linked to/from Python UnicodeDecodeError - Am I misunderstanding encode?
14 votes
2 answers
29k views
Python: Sanitize a string for unicode? [duplicate]
Possible Duplicate: Python UnicodeDecodeError - Am I misunderstanding encode? I have a string that I'm trying to make safe for the unicode() function: >>> s = " foo “bar bar ” weasel" &...
9 votes
1 answer
14k views
Why can't Python print Unicode symbols? [duplicate]
Possible Duplicate: Python UnicodeDecodeError - Am I misunderstanding encode? I am having trouble printing some unicode symbols in Python like this: # encoding: utf-8 print u'ęėįųšįšū' When I try ...
464 votes
10 answers
589k views
How to correct TypeError: Unicode-objects must be encoded before hashing?
I have this error: Traceback (most recent call last): File "python_md5_cracker.py", line 27, in <module> m.update(line) TypeError: Unicode-objects must be encoded before hashing when I try ...
124 votes
12 answers
398k views
UnicodeEncodeError: 'latin-1' codec can't encode character
What could be causing this error when I try to insert a foreign character into the database? >>UnicodeEncodeError: 'latin-1' codec can't encode character u'\u201c' in position 0: ordinal not in ...
103 votes
4 answers
32k views
UnicodeDecodeError when redirecting to file
I run this snippet twice, in the Ubuntu terminal (encoding set to utf-8), once with ./test.py and then with ./test.py >out.txt: uni = u"\u001A\u0BC3\u1451\U0001D10C" print uni Without redirection ...
22 votes
4 answers
17k views
Python 2 vs. Python 3 - urllib formats
I'm getting really tired of trying to figure out why this code works in Python 2 and not in Python 3. I'm just trying to grab a page of json and then parse it. Here's the code in Python 2: import ...
9 votes
3 answers
24k views
Unicode Problem with SQLAlchemy
I know I'm having a problem with a conversion from Unicode but I'm not sure where it's happening. I'm extracting data about a recent Eruopean trip from a directory of HTML files. Some of the ...
4 votes
4 answers
10k views
Can't decode utf-8 string in python on os x terminal.app
I have terminal.app set to accept utf-8 and in bash I can type unicode characters, copy and paste them, but if I start the python shell I can't and if I try to decode unicode I get errors: >>&...
13 votes
2 answers
31k views
Decoding if it's not unicode
I want my function to take an argument that could be an unicode object or a utf-8 encoded string. Inside my function, I want to convert the argument to unicode. I have something like this: def ...
4 votes
6 answers
11k views
Python throws UnicodeEncodeError although I am doing str.decode(). Why?
Consider this function: def escape(text): print repr(text) escaped_chars = [] for c in text: try: c = c.decode('ascii') except UnicodeDecodeError: ...
4 votes
4 answers
18k views
Python UTF-8 can't decode byte on 32-bit machine
it works fine on 64 bit machines but for some reason will not work on python 2.4.3 on a 32-bit instance. i get the error 'utf8' codec can't decode bytes in position 76-79: invalid data for the code ...
6 votes
1 answer
15k views
Python JSON and Unicode
Update : I found the answer here : Python UnicodeDecodeError - Am I misunderstanding encode? I needed to explicitly decode my incoming file into Unicode when I read it. Because it had characters ...
2 votes
4 answers
10k views
Set Python terminal encoding on Windows
I happened to fail to set character encoding in Python terminal on Windows. According to official guide, it's a piece of cake: # -*- coding: utf-8 -*- Ok, now testing: print 'Русский' Produces piece ...
3 votes
2 answers
3k views
how to convert 8-bit hebrew to utf-8 in python
I have hebrew data such that \xe0 is the hebrew aleph, and wish to convert it into utf-8
3 votes
2 answers
3k views
How do you store a non-ASCII character in Google App Engine Datastore
I've tried no less then 5 different "solutions" and i cant get it to work, please help. This is the error 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128) Traceback (...