mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-22 13:16:24 +01:00
Fix #5141 (UnicodeEncodeError: 'ascii' codec can't encode character u'\u03c0' in position 107: ordinal not in range(128))
This commit is contained in:
parent
c6a6fcab2c
commit
f871846e18
1 changed files with 6 additions and 3 deletions
|
|
@ -141,7 +141,8 @@ def _create_html_root(self, hhcpath, log):
|
|||
log.debug('Found %d section nodes' % len(chapters))
|
||||
htmlpath = os.path.splitext(hhcpath)[0] + ".html"
|
||||
f = open(htmlpath, 'wb')
|
||||
f.write("<HTML><HEAD></HEAD><BODY>\r\n")
|
||||
f.write('<html><head><meta http-equiv="Content-type"'
|
||||
' content="text/html;charset=UTF-8" /></head><body>\n')
|
||||
|
||||
if chapters:
|
||||
path0 = chapters[0][1]
|
||||
|
|
@ -152,10 +153,12 @@ def _create_html_root(self, hhcpath, log):
|
|||
rsrcname = os.path.basename(chapter[1])
|
||||
rsrcpath = os.path.join(subpath, rsrcname)
|
||||
# title should already be url encoded
|
||||
url = "<br /><a href=" + rsrcpath + ">" + title + " </a>\r\n"
|
||||
url = "<br /><a href=" + rsrcpath + ">" + title + " </a>\n"
|
||||
if isinstance(url, unicode):
|
||||
url = url.encode('utf-8')
|
||||
f.write(url)
|
||||
|
||||
f.write("</BODY></HTML>")
|
||||
f.write("</body></html>")
|
||||
f.close()
|
||||
return htmlpath
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue