diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index 32f2503b2c..672fd0d295 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -41,7 +41,7 @@ class CSV_XML(CatalogPlugin): log = Log() self.fmt = path_to_output.rpartition('.')[2] - + if False and opts.verbose: log("%s:run" % self.name) log(" path_to_output: %s" % path_to_output) @@ -54,7 +54,7 @@ class CSV_XML(CatalogPlugin): log(" opts:") for key in keys: log(" %s: %s" % (key, opts_dict[key])) - + # Get the sorted, filtered database as a dictionary data = self.search_sort_db(db, opts) @@ -69,7 +69,7 @@ class CSV_XML(CatalogPlugin): outfile = open(path_to_output, 'w') # Output the field headers - outfile.write('%s\n' % ','.join(fields)) + outfile.write(u'%s\n' % u','.join(fields)) # Output the entry fields for entry in data: @@ -80,15 +80,15 @@ class CSV_XML(CatalogPlugin): item = ', '.join(item) if x < len(fields) - 1: if item is not None: - outstr += '"%s",' % str(item).replace('"','""') + outstr += u'"%s",' % unicode(item).replace('"','""') else: outstr += '"",' else: if item is not None: - outstr += '"%s"\n' % str(item).replace('"','""') + outstr += u'"%s"\n' % unicode(item).replace('"','""') else: outstr += '""\n' - outfile.write(outstr) + outfile.write(outstr.encode('utf-8')) outfile.close() elif self.fmt == 'xml':