From f871846e18535f0f706d7f7df7c46dd232c98ffc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 30 Mar 2010 22:20:39 +0530 Subject: [PATCH] Fix #5141 (UnicodeEncodeError: 'ascii' codec can't encode character u'\u03c0' in position 107: ordinal not in range(128)) --- src/calibre/ebooks/chm/input.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/chm/input.py b/src/calibre/ebooks/chm/input.py index 3f0aa21f08..a3a49296d2 100644 --- a/src/calibre/ebooks/chm/input.py +++ b/src/calibre/ebooks/chm/input.py @@ -141,7 +141,8 @@ class CHMInput(InputFormatPlugin): log.debug('Found %d section nodes' % len(chapters)) htmlpath = os.path.splitext(hhcpath)[0] + ".html" f = open(htmlpath, 'wb') - f.write("\r\n") + f.write('\n') if chapters: path0 = chapters[0][1] @@ -152,10 +153,12 @@ class CHMInput(InputFormatPlugin): rsrcname = os.path.basename(chapter[1]) rsrcpath = os.path.join(subpath, rsrcname) # title should already be url encoded - url = "
" + title + " \r\n" + url = "
" + title + " \n" + if isinstance(url, unicode): + url = url.encode('utf-8') f.write(url) - f.write("") + f.write("") f.close() return htmlpath