From fce9c872517d4774c54339f5d38b589e073f1027 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 13 Nov 2008 15:33:49 -0800 Subject: [PATCH] Fix #1261 (html2epub doesn't support CJK characters in css style) --- src/calibre/ebooks/epub/from_html.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/epub/from_html.py b/src/calibre/ebooks/epub/from_html.py index 6900193cba..0c45a6de6f 100644 --- a/src/calibre/ebooks/epub/from_html.py +++ b/src/calibre/ebooks/epub/from_html.py @@ -121,7 +121,10 @@ def parse_content(filelist, opts, tdir): if opts.base_font_size2 > 0: Rationalizer.remove_font_size_information(stylesheets.values()) for path, css in stylesheets.items(): - open(path, 'wb').write(getattr(css, 'cssText', css).encode('utf-8')) + raw = getattr(css, 'cssText', css) + if isinstance(raw, unicode): + raw = raw.encode('utf-8') + open(path, 'wb').write(raw) if toc.count('chapter') > opts.toc_threshold: toc.purge(['file', 'link', 'unknown']) if toc.count('chapter') + toc.count('file') > opts.toc_threshold: