View Single Post
Old 07-23-2014, 09:30 AM   #10
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,410
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Again, unicode objects in python are not utf-8, they are either utf-16 or ucs-4 depending on compile time options.

Do this:

Code:
if isintance(u_genre, bytes):
  u_genre = u_genre.decode('utf-8')
before you use u_genre anywhere.

And from the sound of it "totally supports utf-8" is totally incorrect, if it is yielding bytestrings from the csv file instead of unicode objects.
kovidgoyal is offline   Reply With Quote