mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Fix unicode support in CSV catalog output
This commit is contained in:
parent
d96910f3ea
commit
03c5a395f3
@ -41,7 +41,7 @@ class CSV_XML(CatalogPlugin):
|
|||||||
|
|
||||||
log = Log()
|
log = Log()
|
||||||
self.fmt = path_to_output.rpartition('.')[2]
|
self.fmt = path_to_output.rpartition('.')[2]
|
||||||
|
|
||||||
if False and opts.verbose:
|
if False and opts.verbose:
|
||||||
log("%s:run" % self.name)
|
log("%s:run" % self.name)
|
||||||
log(" path_to_output: %s" % path_to_output)
|
log(" path_to_output: %s" % path_to_output)
|
||||||
@ -54,7 +54,7 @@ class CSV_XML(CatalogPlugin):
|
|||||||
log(" opts:")
|
log(" opts:")
|
||||||
for key in keys:
|
for key in keys:
|
||||||
log(" %s: %s" % (key, opts_dict[key]))
|
log(" %s: %s" % (key, opts_dict[key]))
|
||||||
|
|
||||||
# Get the sorted, filtered database as a dictionary
|
# Get the sorted, filtered database as a dictionary
|
||||||
data = self.search_sort_db(db, opts)
|
data = self.search_sort_db(db, opts)
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ class CSV_XML(CatalogPlugin):
|
|||||||
outfile = open(path_to_output, 'w')
|
outfile = open(path_to_output, 'w')
|
||||||
|
|
||||||
# Output the field headers
|
# Output the field headers
|
||||||
outfile.write('%s\n' % ','.join(fields))
|
outfile.write(u'%s\n' % u','.join(fields))
|
||||||
|
|
||||||
# Output the entry fields
|
# Output the entry fields
|
||||||
for entry in data:
|
for entry in data:
|
||||||
@ -80,15 +80,15 @@ class CSV_XML(CatalogPlugin):
|
|||||||
item = ', '.join(item)
|
item = ', '.join(item)
|
||||||
if x < len(fields) - 1:
|
if x < len(fields) - 1:
|
||||||
if item is not None:
|
if item is not None:
|
||||||
outstr += '"%s",' % str(item).replace('"','""')
|
outstr += u'"%s",' % unicode(item).replace('"','""')
|
||||||
else:
|
else:
|
||||||
outstr += '"",'
|
outstr += '"",'
|
||||||
else:
|
else:
|
||||||
if item is not None:
|
if item is not None:
|
||||||
outstr += '"%s"\n' % str(item).replace('"','""')
|
outstr += u'"%s"\n' % unicode(item).replace('"','""')
|
||||||
else:
|
else:
|
||||||
outstr += '""\n'
|
outstr += '""\n'
|
||||||
outfile.write(outstr)
|
outfile.write(outstr.encode('utf-8'))
|
||||||
outfile.close()
|
outfile.close()
|
||||||
|
|
||||||
elif self.fmt == 'xml':
|
elif self.fmt == 'xml':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user