mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix ebook catalog generation on linux systems where the encoding is not UTF-8. Fixes #1048404 (Catalog generation fails)
This commit is contained in:
parent
c77f9a7834
commit
61e13950a3
@ -211,15 +211,15 @@ class CatalogBuilder(object):
|
|||||||
(str): sort key
|
(str): sort key
|
||||||
"""
|
"""
|
||||||
if not book['series']:
|
if not book['series']:
|
||||||
fs = '{:<%d}!{!s}' % longest_author_sort
|
fs = u'{:<%d}!{!s}' % longest_author_sort
|
||||||
key = fs.format(capitalize(book['author_sort']),
|
key = fs.format(capitalize(book['author_sort']),
|
||||||
capitalize(book['title_sort']))
|
capitalize(book['title_sort']))
|
||||||
else:
|
else:
|
||||||
index = book['series_index']
|
index = book['series_index']
|
||||||
integer = int(index)
|
integer = int(index)
|
||||||
fraction = index-integer
|
fraction = index-integer
|
||||||
series_index = '%04d%s' % (integer, str('%0.4f' % fraction).lstrip('0'))
|
series_index = u'%04d%s' % (integer, str(u'%0.4f' % fraction).lstrip(u'0'))
|
||||||
fs = '{:<%d}~{!s}{!s}' % longest_author_sort
|
fs = u'{:<%d}~{!s}{!s}' % longest_author_sort
|
||||||
key = fs.format(capitalize(book['author_sort']),
|
key = fs.format(capitalize(book['author_sort']),
|
||||||
self.generate_sort_title(book['series']),
|
self.generate_sort_title(book['series']),
|
||||||
series_index)
|
series_index)
|
||||||
@ -2464,7 +2464,9 @@ class CatalogBuilder(object):
|
|||||||
title_str=title_str,
|
title_str=title_str,
|
||||||
xmlns=XHTML_NS,
|
xmlns=XHTML_NS,
|
||||||
)
|
)
|
||||||
|
for k, v in args.iteritems():
|
||||||
|
if isbytestring(v):
|
||||||
|
args[k] = v.decode('utf-8')
|
||||||
generated_html = P('catalog/template.xhtml',
|
generated_html = P('catalog/template.xhtml',
|
||||||
data=True).decode('utf-8').format(**args)
|
data=True).decode('utf-8').format(**args)
|
||||||
generated_html = substitute_entites(generated_html)
|
generated_html = substitute_entites(generated_html)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user