Linked Questions

14 votes
2 answers
29k views

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" &...
Nick Heiner's user avatar
9 votes
1 answer
14k views

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 ...
Euphorbium's user avatar
  • 1,277
464 votes
10 answers
589k views

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 ...
JohnnyFromBF's user avatar
  • 10.2k
124 votes
12 answers
398k views

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 ...
ensnare's user avatar
  • 42.5k
103 votes
4 answers
32k views

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 ...
zedoo's user avatar
  • 11.4k
22 votes
4 answers
17k views

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 ...
Dan Lew's user avatar
  • 87.7k
9 votes
3 answers
24k views

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 ...
Dave Forgac's user avatar
  • 3,334
4 votes
4 answers
10k views

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: >>&...
Bjorn's user avatar
  • 72.4k
13 votes
2 answers
31k views

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 ...
Manuel Ceron's user avatar
  • 8,496
4 votes
6 answers
11k views

Consider this function: def escape(text): print repr(text) escaped_chars = [] for c in text: try: c = c.decode('ascii') except UnicodeDecodeError: ...
Aufwind's user avatar
  • 26.4k
4 votes
4 answers
18k views

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 ...
JiminyCricket's user avatar
6 votes
1 answer
15k views

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 ...
interstar's user avatar
  • 27.5k
2 votes
4 answers
10k views

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 ...
Arnthor's user avatar
  • 2,623
3 votes
2 answers
3k views

I have hebrew data such that \xe0 is the hebrew aleph, and wish to convert it into utf-8
Daniel Braniss's user avatar
3 votes
2 answers
3k views

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 (...
user avatar

15 30 50 per page