UnicodeDecodeErrors in Python

First thing to check if using mysql:

Make sure db connection is (note the charset, and use_unicode)

db = MySQLdb.connect(host=dbserver, user=dbuser, passwd=dbpass, db=dbname, charset = "utf8", use_unicode = True)


Posted by JB Uy on September 24, 2013 at 08:22 PM UTC
Edited on December 13, 2013 at 08:43 PM UTC
4 Notes

Still confused about this in Python.

More links: http://stackoverflow.com/questions/10288016/usage-...

Posted by JB Uy on June 10, 2014 at 09:24 PM UTC
via hutility.notedock.com | Link

http://www.evanjones.ca/python-utf8.html

http://effbot.org/zone/unicode-objects.htm

Posted by JB Uy on November 27, 2013 at 01:12 AM UTC
Edited on November 27, 2013 at 01:51 AM UTC
via hutility.notedock.com | Link

ie.

x = u'Jübber'

We cannot do:

x = x.encode('utf8')
str(x)

Hence, we CANNOT encode then do string ops:

x = x.encode('utf8')
y = 'abc'
...
word = str(x) + str(y)

But we CAN do:

x = x.encode('utf8')
y = 'abc'
...
word = x + str(y)

Then 'word' would be unicode

Posted by JB Uy on November 26, 2013 at 11:54 PM UTC
Edited on December 13, 2013 at 08:43 PM UTC
via hutility.notedock.com | Link

On using urllib to quote and unquote unicode in URLs

http://stackoverflow.com/questions/5139249/python-url-unquote-unicode

Posted by JB Uy on October 21, 2013 at 10:03 PM UTC
via hutility.notedock.com | Link
Public Comments
comments powered by Disqus