From 5d2772eb7307d24dabef2458af1fb499c379af71 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 17 Oct 2010 15:34:29 -0600 Subject: [PATCH] EPUB Input: Handle EPUB files with components encoded in an encoding other than UTF-8 correctly, though why anyone would do that is a mystery. Fixes #7196 (Non UTF-8 in ePub) --- src/calibre/customize/conversion.py | 5 +++++ src/calibre/ebooks/conversion/plumber.py | 3 ++- src/calibre/ebooks/epub/input.py | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/calibre/customize/conversion.py b/src/calibre/customize/conversion.py index 8c8ce8c686..c36f83bd2f 100644 --- a/src/calibre/customize/conversion.py +++ b/src/calibre/customize/conversion.py @@ -120,6 +120,11 @@ class InputFormatPlugin(Plugin): #: to make its output suitable for viewing for_viewer = False + #: The encoding that this input plugin creates files in. A value of + #: None means that the encoding is undefined and must be + #: detected individually + output_encoding = 'utf-8' + #: Options shared by all Input format plugins. Do not override #: in sub-classes. Use :attr:`options` instead. Every option must be an #: instance of :class:`OptionRecommendation`. diff --git a/src/calibre/ebooks/conversion/plumber.py b/src/calibre/ebooks/conversion/plumber.py index 9bab688ba5..f520365c1c 100644 --- a/src/calibre/ebooks/conversion/plumber.py +++ b/src/calibre/ebooks/conversion/plumber.py @@ -838,7 +838,8 @@ OptionRecommendation(name='timestamp', self.opts_to_mi(self.user_metadata) if not hasattr(self.oeb, 'manifest'): self.oeb = create_oebbook(self.log, self.oeb, self.opts, - self.input_plugin) + self.input_plugin, + encoding=self.input_plugin.output_encoding) self.input_plugin.postprocess_book(self.oeb, self.opts, self.log) self.opts.is_image_collection = self.input_plugin.is_image_collection pr = CompositeProgressReporter(0.34, 0.67, self.ui_reporter) diff --git a/src/calibre/ebooks/epub/input.py b/src/calibre/ebooks/epub/input.py index cdd69ea50f..30a3327b63 100644 --- a/src/calibre/ebooks/epub/input.py +++ b/src/calibre/ebooks/epub/input.py @@ -16,6 +16,7 @@ class EPUBInput(InputFormatPlugin): author = 'Kovid Goyal' description = 'Convert EPUB files (.epub) to HTML' file_types = set(['epub']) + output_encoding = None recommendations = set([('page_breaks_before', '/', OptionRecommendation.MED)])