diff --git a/src/calibre/ebooks/htmlz/input.py b/src/calibre/ebooks/htmlz/input.py index 6822f91b68..dcf2ed0ed3 100644 --- a/src/calibre/ebooks/htmlz/input.py +++ b/src/calibre/ebooks/htmlz/input.py @@ -10,6 +10,7 @@ import os from calibre import walk from calibre.customize.conversion import InputFormatPlugin +from calibre.ebooks.chardet import xml_to_unicode from calibre.utils.zipfile import ZipFile class HTMLZInput(InputFormatPlugin): @@ -34,6 +35,13 @@ class HTMLZInput(InputFormatPlugin): html = tf.read() break + # Encoding + if options.input_encoding: + ienc = options.input_encoding + else: + ienc = xml_to_unicode(html[:4096])[-1] + html = html.decode(ienc, 'replace') + # Run the HTML through the html processing plugin. from calibre.customize.ui import plugin_for_input_format html_input = plugin_for_input_format('html')